1

I have a website which extensively uses files which are static like Jquery library, images and some other functionality JS files.

So, I wish to set infinite expiry time for those resources so that those can be easily retrieved from users cache. This will enhance his experience and reduce the loading file

Can anyone suggest how to do the same using .htaccess or any other method.

Thanks !

Prashant Singh
  • 3,725
  • 12
  • 62
  • 106

1 Answers1

1

http://httpd.apache.org/docs/current/mod/mod_expires.html You might be looking for the ExpiresByType directive? I suppose, setting it to 10 years will be sufficient. However, be careful with updates to those files then.

PhilMasteG
  • 3,095
  • 1
  • 20
  • 27
  • But that specifies only category wise caching. How can I make it file wise ? Can you please give a specific format ? – Prashant Singh Jul 22 '12 at 06:48
  • Oh you meany by file, not by type. Hm, how about putting those files into a separate directory and setting `ExpiresDefault` in a separate `.htaccess` in that directory. Like `/static`. – PhilMasteG Jul 22 '12 at 06:53
  • I used this answer to set .htaccess file http://webmasters.stackexchange.com/questions/5265/how-do-i-set-expiration-headers-for-css-js-and-images , still, cache-control attribute is set to no-cache in my browser,i.e, the code is only setting max-age etc. Any help in changing the cache-control attribute ? – Prashant Singh Jul 22 '12 at 07:05
  • Have you checked to load the modules mod_expires and mod_headers? – PhilMasteG Jul 22 '12 at 07:09