Any way to force reset of all cached static files on AppEngine?
Solution 1
It the depends on what cache-control is used. Check in firebug och chrome inspector and see what expiration date are set.
If you've set the cache-control to public you can't affect the control since the files are cache on various proxies and server along the way.
If you use cache-control private you should be able to reset you browser cache and be fine, but as you say sometimes you get the wrong files from Google's production environment. I've had the same problem. The fastest solution is to add a query param to the files loaded.
Solution 2
There is a way to shorten the expiration time for static files cached by your app on Google Cloud.
Head to your Google Cloud Console and open your project. Under the left hamburger menu, head to Storage -> Browser. There you should find at least one Bucket: your-project-name.appspot.com. Under the Lifecycle column, click on the link with respect to your-project-name.appspot.com. Delete any existing rules, since they may conflict with the one you will create now.
Create a new rule by clicking on the 'Add rule' button. For the object conditions, choose only the 'Newer version' option and set it to 1. Don't forget to click on the 'Continue' button. For the action, select 'Delete' and click on the 'Continue' button. Save your new rule.
This new rule will take up to 24 hours to take effect, but at least for my project it took only a few minutes. Once it is up and running, the version of the files being served by your app under your-project-name.appspot.com will always be the latest deployed, solving the problem. Also, if you are routinely editing your static files, you should remove any expiration
element from handlers related to those static files and the default_expiration
element from the app.yaml file, which will help avoid unintended caching by other servers.
Related videos on Youtube
Andrew Johnson
Co-founder of TrailBehind, Inc. Our mobile mapping platform powers the best hiking app, the best boating app, the only real-time whale-tracking app, the as-official-as-it-gets Burning Man app, and other apps for the network's fringe. Check out Gaia GPS, Whale Alert, Marine Charts, Shark Net, Offline Topo Maps, EFB (Flight Charts), Benchmark California Atlas, Fine Local Wine, and StopWatch+. Email me at [email protected], particularly if you live near Berkeley. http://twitter.com/trailbehind http://github.com/trailbehind
Updated on September 14, 2022Comments
-
Andrew Johnson over 1 year
I am running into a known AppEngine issue where the wrong static content is cached if I go to a particular URL for my app, but the right static content shows up if I append a ?foo parameter to bust the cache, and VERSION.myapp.appspot.com works too.
Is there any way to get the correct content showing up at the unmodified URL?
I would be happy to delete the app and restore it or anything drastic. The app isn't live, but I need it to be in a couple of hours. Anything to get those URLS working so the mobile app talking to the AppEngine app gets the right data.
EDIT
cURLing the headers, I see:
HTTP/1.1 200 OK ETag: "ZN9VxQ" Date: Tue, 14 Aug 2012 02:00:58 GMT Expires: Wed, 15 Aug 2012 02:00:58 GMT Content-Type: text/html Server: Google Frontend Cache-Control: public, max-age=86400 Age: 34623 Transfer-Encoding: chunked
Am I hosed for another 50,000 seconds? Anyway to shorten that?
EDIT FOR COMMENTS:
In app.yaml, I have this handler:
- url: /static static_dir: static expiration: 1s
I have now tried removing the expiration:
- url: /static static_dir: static
And I added this to the top of app.yaml, based on the docs:
default_expiration: "1m"
Also, deleting files doesn't make them disappear when I deploy.
-
Andrew Johnson over 11 yearsIf that's the case, how long does that cache last? And I'm not sure... I was just using myapp.appspot.com, but after this problem was in progress, my colleague did register a domain to redirect to the URL... would that matter?
-
-
Константин Константин over 2 yearsit isn't a answer, check answer above