On GAE python 2.7 I have a single folder where I serve my CSS and JS files. The handler in my app.yaml looks like this:
- url: /scripts
static_dir: scripts
expiration: '30d'
Some of the JS files are cached the first time around, and subsequent page loads will fetch the JS directly from the browser cache. However, the browser uses conditional GET requests to fetch the CSS. The latency for this request is still sluggish on a 3G connection.
Is there any specification that says CSS can't be cached in the browser? Any idea why GAE caches the different files differently?
My site is accessible at http://test.dine-o.com/dine
Notice the difference between zepto.min.js or plate-min-####.js which are fetched from the browser cache, and plate-min.####.css which is fetched with a conditional GET.
The main problem I was trying to work around was conditional GETs being issued for CSS files when I refreshed the page. I assumed this was because cache related headers weren't being set.
It looks like the headers are being set. A clean GET request does show appropriate headers for cache-control, etag, and expires.
It looks like I'm running into browser behavior. I'm not sure if this is standard, but the behavior somehwat matches the "User Invoked Refresh" behavior described here: http://blogs.msdn.com/b/ieinternals/archive/2010/07/08/technical-information-about-conditional-http-requests-and-the-refresh-button.aspx
If I use a browser reload, Chrome issues a conditonal GET for CSS. In this case, some of the cache headers are not present, which was what made me think the problem was server side initially.
If I go to the URL bar and hit ENTER, Chrome will fetch the CSS purely from cache.
The only solution I can think of is to use AppCache.