2

I set a cache-control on my server of 1 year. How to say to the AppEngine "clear !" to take a new version from the server ?

enter image description here

The configuration is Flex custom environment

runtime: custom
env: flex

env_variables:
    writecontrolEnv: 'prod'

handlers:
- url: /.*
  script: this field is required, but ignored

service: gateway-prod

automatic_scaling:
  min_num_instances: 1
  max_num_instances: 2

resources:
  cpu: 1
  memory_gb: 2
  disk_size_gb: 10

skip_files:
- node_modules/

network:
  instance_tag: gateway
maxiplay
  • 427
  • 1
  • 5
  • 13
  • 1
    Dan's answer is very good. For this problem I would change the filenames (and implement versioning in the filename). This way you can keep long cache times. When you need to perform an update, change the filename's version part. – John Hanley Dec 14 '18 at 20:21
  • I would hope an other response that just change the filenames of the entire project ! I'm using service worker and don't need to manage my-self the versioning. – maxiplay Dec 15 '18 at 07:50
  • Other question : How to change the name of the index.html page ? Users will continue to go to "/" url and they won't add manually a version number to the url – maxiplay Dec 15 '18 at 15:54
  • Do not specify long caching for HTML files. You specify caching and filename versioning for JavaScript and CSS that builds the pages. For the actual page such as index.html, specify short cache times or none at all. – John Hanley Dec 15 '18 at 15:59
  • Thx but it's too late ^^ How to solve this ? – maxiplay Dec 15 '18 at 16:08
  • cache busting / versioning is the only solution that worked for me – saccodd Jun 30 '19 at 20:11

1 Answers1

1

Assuming that your app is the one serving the static files then the cache parameters sent by the server are controlled by your application code. Which means that once you deploy a new version with updates parameters the server will send the updated values.

But the problem is that caching is actually performed by the client (or some middle-man network device), so the end user will not reach to the server until the (very long in your case) cache expiration time is reached, so it won't see the update until then.

You can try to clear your browser cache, hoping that the browser was the one doing the cache-ing.

To prevent such occurrences in the future you may want to choose a shorter cache expiration time or use some cache busting technique like this one.

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • The browser cache is not a problem. The problem is even is the browser cache is cleared, Google App engine server cache (nginx ?) keep the old version and don't touch the server – maxiplay Dec 15 '18 at 07:48
  • How did you reach that conclusion? The server restarts every time your instance restarts. – Dan Cornilescu Dec 15 '18 at 13:41
  • I disable cache in browser, disable service worker, Restart or update server and I always get the version of last month for the static files. If i try with the www version, i have the last version – maxiplay Dec 15 '18 at 15:13
  • OK, that's an inconsistent behaviour, a completely different game. You may have instances for multiple versions active or you're making changes of the live instances (which are ephemeral). You'll have to describe it exactly and in detail. your last comment is not covering all cases: how about restart with www version (whatever that means as you didn't specify exactly) – Dan Cornilescu Dec 15 '18 at 16:32
  • Instances are ephemeral but Google public cache keep the old scripts in memory – maxiplay Dec 16 '18 at 12:22