Preventing Caching of CSS Files Preventing Caching of CSS Files apache apache

Preventing Caching of CSS Files


I've ran across this problem a few times and usually over come the problem on production sites by calling my css like this

<link rel="stylesheet" type="text/css" href="style.css?v=1" />

When you roll out an update just change the v=1 to v=2 and it will force all of your users browsers to grab the new style sheets. This will work for script files as well. If you view source on Google you will notice they use this approach as well.


I used to have the same problem with my LAMP dev system, caused by a network mount. I managed to get rid of it by adding these two lines to my apache conf.

EnableMMAP offEnableSendfile off


In my php pages i usually add the current date time to the end of your css href:

<link rel="stylesheet" type="text/css" href="style.css?<?php echo date('l jS \of F Y h:i:s A'); ?>" />

Ref : Here