As suggested by an answer on SO, I'm trying using a version number on my JS and CSS files so that the browser will only make a request when the JS or CSS version number is changed in my PHP file. To facilitate this, I have a rewrite in my
httpd.conf which transforms a requested file like
myscript.js. Since I'm doing things this way, I want the browser to cache the file for a long time, since it will see a request for a "different" file when that version number is updated.
According to an answer on Webmasters.SE, I can use
FilesMatch along with
Header set Cache-Control to only cache the CSS/JS files with the version number on them.
And according to an answer on SO, only
Cache-Control is necessary, since it takes precedence over
But this is not working. The
Cache-Control header field is missing from the response.
Here's my Apache configuration:
Here's a request for one of the JS files: