Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine: How to disable cache on 'static' files, or make cache smart

I'm using the app engine locally, and sometimes the JS files are being cached between page refreshes, and it drives me crazy because I don't know if there's a bug in the javascript code I'm trying to write, or if the cache is acting up.

How do I completely disable cache for *.js files? Or maybe the question is, how to have it be smart, like based on last-modified date.

Thanks!

UPDATE- So it turns out Chrome Dev (for mac at least) has caching issues, going back to Chrome Beta fixes all this. The answers have still been helpful though, thanks

like image 768
adamJLev Avatar asked Apr 15 '10 02:04

adamJLev


1 Answers

A common practice used by the major sites is to cache documents forever but include a unique identifier based on the release version or date into the url for the .js or .css call. For example:

<script type="text/javascript" src="static/util.js?version=20100310"></script>

This way you get optimum caching as well as always up to date files. The only trick is to figure out how to include an up to date version number in your url, which you can automate based on your deployment environment.

like image 76
Parand Avatar answered Sep 20 '22 21:09

Parand