Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

The problem may be related to "login as Admin" functions provided by appengine. According to this post,

the presence of the "X-AppEngine" headers indicates that the requesting user agent was logged in as an administrator. When these headers are present, App Engine will suppress caching on the response, to keep these headers from being cached and served to other users.

Responses for non-administrator users shouldn't have X-AppEngine headers, and shouldn't trigger cache suppression.

gae suppress the caching ability when a user is logged in as an admin of the site to avoid the "X-Appengine" being cached

I have a similar non-cache problem on my site though I specify certain pages to be cached and expire. Not sure whether it applies to your case or not though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top