RewriteCond %{REQUEST_URI} ^/[images|css|js]/
RewriteRule ^/(.*)$ /$1?ver=2 [L]
Now am using this code. But its not working.
RewriteCond %{REQUEST_URI} ^/[images|css|js]/
RewriteRule ^/(.*)$ /$1?ver=2 [L]
Now am using this code. But its not working.
Htaccess solution :
You might want to use mod_headers
functions Cache-Control
and Expires
, for the file types you want the browser to not cache :
<filesMatch "\.(js|css|jpg|jpeg|png|gif)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>
PHP solution :
You could also load each resource with a different timestamp each time your page is shown :
<script type="text/javascript" src="myfile.js?time=<?php echo mktime(); ?>" />
<link rel="stylesheet" media="screen" href="/myfile.css?time=<?php echo mktime(); ?>">