Keith Bentrup
Keith Bentrup

Reputation: 11975

What caching headers prevent browsers from requesting last modified dates from the server?

Since I version all my css/js/images, they never "change". It might go from sprite.4.png to sprite.5.png, but sprite.4.png will never change.

Anyway, it seems pointless for the browsers to be checking for modified versions and receiving 304 responses, so what do I need to put in .htaccess to prevent these last modified look ups?

Right now I have,

<ifmodule mod_expires.c>
  <filesmatch "\.(jpg|gif|png|css|js|swf)$">
   ExpiresActive On
   ExpiresDefault "access plus 10 years"
   </filesmatch>
</ifmodule>

but I still see the 304's in the browsers. What else do I need? Thanks.

Upvotes: 1

Views: 629

Answers (1)

Philippe Leybaert
Philippe Leybaert

Reputation: 171734

You could also add:

Cache-Control: public

to the headers. That will allow clients and proxies to cache the output

In .htaccess:

   <filesmatch "\.(jpg|gif|png|css|js|swf)$">
       Header set Cache-Control "max-age=1000000000, public"
   </filesmatch>

Upvotes: 1

Related Questions