How can I cache a few specific JavaScript & CSS files. I found advice from this site to put this in my .htaccess
file
AddOutputFilter DEFLAT
You can configure IIS to cache specific files by extension. For example:
Select the folder where your css/js files reside and then click on Output Caching.
Then add the file extensions that you want to cache:
I don't think you can specify which ones to cache on a per file basis unless you write an http handler module to add the appropriate headers for each file independently, but from IIS this is how is done.
Then you can verify that you are getting 304 responses using firebug / fiddler or your tool of choice.
I hope this is helpful.
That's cool i would anyways add a file revisions and make IIS cache css + js files. As Icarus specified.
Then if you update the files on the server just add a new revision number this could also be a timestamp.
css & js
your css and js.Expires
and cache control headers to On application/x-javascript
to a month A2592000 => 24 * 3600 * 30
its in ms
.I would recommend to instead of handling specific js via .htaccess you should add a revisions number to your js files, ala:
<script src="link/to/file.js?rev=xxx"></script>
Then when you update your files just update the rev number. And your clients will automatically be served the new files.
Resources: