Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS File Not Updating on Deploy (Google AppEngine)

I pushed a new version of my website, but now the CSS and static images are not deploying properly.

Here is the messed up page: http://www.gaiagps.com

Appengine shows the latest version as being correct though: http://1.latest.gaiagps.appspot.com/

Any help?

like image 440
Andrew Johnson Avatar asked May 06 '10 17:05

Andrew Johnson


4 Answers

I've seen this before on App Engine, even when using cache-busting query parameters like /stylesheets/default.css?{{ App.Version }}.

Here's my (unconfirmed) theory:

  1. You push a new version by deploying or changing a new version to default.
  2. While this update is being propagated to all GAE instances running your app...
  3. ...someone hits your site.
  4. The request for static resource default.css{{ App.Version }} is sent to Google's CDN, which doesn't yet have it.
  5. Google's CDN asks GAE for the resource before propagation from step #2 is done for all instances.
  6. If you're unlucky, GAE serves up the resource from an instance running the old version...
  7. ...which now gets cached in Google's CDN as the authoritative "new" version.

When this (if this is what happens) happens, I can confirm that no amount of cache-busting browser work will help. The Google CDN servers are holding the wrong version.

To fix: The only way I've found to fix this is to deploy another version. You don't run the risk of this happening again (if you haven't made any CSS changes since the race condition), because even if the race condition occurs, presumably your first update is done by the time you deploy your second one, so all instances will be serving the correct version no matter what.

like image 63
kamens Avatar answered Nov 11 '22 00:11

kamens


Following is what has worked for me.

  1. Serve your css file from the static domain. This is automatically created by GAE.

    //static.{your-app-id}.appspot.com/{css-file-path}

  2. Deploy your application. At this point your app will be broken.

  3. change the version of the css file

    //static.{your-app-id}.appspot.com/{css-file-path}?v={version-Name}

  4. deploy again.

Every time you change the css file. you will have to repeat 2,3 and 4.

like image 36
coderman Avatar answered Nov 10 '22 23:11

coderman


Your link looks fine to me, unless I'm missing something.

You may have cached your old CSS, and not getting the new CSS after updating it. Try clearing your browser cache and see if that works.

Going to 1.latest downloads the new CSS since it's not in your cache, so it appears correctly to you.

like image 2
Jason Hall Avatar answered Nov 11 '22 00:11

Jason Hall


I had this problem as well. I was using flask with GAE so I didn't have a static handler in my app.yaml. When I added it, the deploy works. Try adding something like this

handlers:
- url: /static
  static_dir: static

to your app.yaml and deploy again. It worked for me. Apparently Google is trying to optimize by not updating files that it thinks users can't see.

like image 2
user792036 Avatar answered Nov 10 '22 23:11

user792036