Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App Engine: Static Files Not Updating on Deploy

I pushed an HTML static file containing an Angular SPA as catch-all handler for my custom domain with this settings:

- url: /(api|activate|associate|c|close_fb|combine|import|password|sitemap)($|/.*)
  script: gae.php

- url: /.*
  static_files: public/static/app/v248/es/app.html
  upload: public/static/app/v248/es/app.html
  expiration: "1h"

That worked fine, but if I push a new app.html it doesn't update. I've tried to change the local path, deploy a new app version, even replacing the catch-all handler with a custom php endpoint, but it doesn't work, the response still is the first version of app.html I uploaded.

Other people has had the same problem (CSS File Not Updating on Deploy (Google AppEngine)), and it looks like is related to Google CDN cache but, as far as I know, there isn't any way to flush it.

like image 664
Javier Marín Avatar asked Oct 19 '15 20:10

Javier Marín


2 Answers

There is a way to flush 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 -> Cloud 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 A Rule' button. For the action, select "Set storage to nearline". For the object conditions, choose only the 'Number of newer versions' option and set it to 1. Click on the 'Continue' button and then click 'Create'.

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.

like image 143
Gabriel H. Nunes Avatar answered Sep 29 '22 21:09

Gabriel H. Nunes


2020 Update:

For my application I found that App Engine started failing to detect my latest app deployments once I reached 50 Versions in my Versions list.

See (Burger Menu) -> App Engine -> Versions

After deleting a bunch of old versions on next deploy it picked up my latest changes immediately. Not sure if this is specific to my account or billing settings but that solved it for me.

like image 38
Ergin Avatar answered Sep 29 '22 22:09

Ergin