App Engine: Static Files Not Updating on Deploy

前端 未结 4 1743
不思量自难忘°
不思量自难忘° 2021-02-14 10:12

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|         


        
相关标签:
4条回答
  • 2021-02-14 10:50

    When performing changes in static files in an App Engine application, changes will not be available immediately, due to cache, as you already imagined. The cache in Google Cloud cannot be manually flushed, so instead I would recommend you to change the expiration time to a shorter period (by default it is 10 minutes) if you want to test how it works, and later setting an appropriate expiration time according to your requirements.

    Bear in mind that you can change the static cache expiration time both for all static files or for just the ones you choose, just by setting the proper element in the app.yaml file.

    0 讨论(0)
  • 2021-02-14 11:16

    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.

    0 讨论(0)
  • 2021-02-14 11:16

    I had my static files over a service in Google Cloud Platform. My problem was that I didn't execute

    gcloud app deploy dispatch.yaml
    

    Once executed, everything was fine. I hope it helps

    0 讨论(0)
  • 2021-02-14 11:17

    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 -> 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.

    0 讨论(0)
提交回复
热议问题