I'm using Nginx as web server and Firefox to view response headers. For testing, I had two files on the server with the same content: test.html and test.php. In the Nginx configuration file, the expires directive is set to 30d in the server context.
When accessing test.html in a web browser multiple times, the browser first obtains a 304 Not Modified response and serves a copy cached in the browser. However, when accessing test.php, the browser always makes a full request to the server (200 OK) without using the browser cache.
The questions are:
nginx sets the response header for the static file, included in the headers are:
Cache-Control
Expires
Last-Modified
Cache-Control
tells the client (at least) how to cache the content.
Expires
and Last-Modified
allow the client to determine when to fetch new content.
What you must do is ensure that PHP sends the same headers, or sensible headers if not exactly the same; Now that you know which headers are important, inspecting the requests in your browser will tell you how to achieve this.