Caching version controlled CSS file in apache

112 views Asked by At

I have seen quite a posts on how to successfully control caching of the css and othe static files using mod_expire.

However our application uses version as query string to bust the caching of stale css, e.g stylesheet.css?v=2.1

I made all the configurations as required and restarted the application also but am still seeing the browser is trying to get the css from the server. I don't see a 304 for these file types.

I even tried changing the file pattern in the vhost file to match it :( but still no 304.

Is there anything I am missing?

EDIT

<IfModule mod_expires.c>
<FilesMatch "\.(jpe?g|png|gif|js|css)$">
    ExpiresActive On
    ExpiresDefault "access plus 30 day"
</FilesMatch>

this is inside the vhost file.

I also tried to replace the regex pattern to \.(jpe?g|png|gif|js|css).*

which I know I will break the future releases but I had to try it.

the http header for one of the CSS is

accept-ranges: bytes
access-control-allow-origin: *
cache-control: max-age=2592000
content-length: 2572
content-type: text/css
date: Sat, 06 Mar 2021 04:13:26 GMT
etag: "a0c-5bc3f3f07f180"
expires: Mon, 05 Apr 2021 04:13:26 GMT
last-modified: Fri, 26 Feb 2021 15:51:50 GMT
server: Apache/2.4.46 (Amazon) PHP/7.2.34

I see the expiry is set but what is intriguing is that the status code is 200, should not it be 304?

0

There are 0 answers