Rajsekar Reddy
Rajsekar Reddy

Reputation: 101

updated content only loads on hard refresh, else it loads old content

We have an laminas application which uses Akamai, Varnish and Memcache

currently we have updated 404 page with updated content on it, but it loads old content on load/refresh and only loads fresh content on hard refresh Before is the URL in question https://www.suncamp.co.uk/saflkjshf/

What did i try: I have tried to delete & invalidated akamai, varnish and memcache for the URL https://www.suncamp.co.uk but no luck

Upvotes: 0

Views: 40

Answers (2)

Don't set long TTL for 404 response codes. Always recommend to set low TTL value of error status codes if we prefer to cache on CDN or Browser end.

Also set last-modified header on response. so the browser will always send if-modified-since request header to revalidate the cache after the TTL ends on browser end.

Set no-cache for all 5xx and 4xx and clear varnish, CDN cache to overall domain once.

Upvotes: 0

Thijs Feryn
Thijs Feryn

Reputation: 4818

Content that you store in the cache has a TTL. For HTTP caches like Varnish the Cache-Control header can be used to define that TTL.

I see that in your case the value is Cache-Control: max-age=604794. This mean the object lives in the cache for 604794 seconds. A hard browser refresh has no impact on the cache, because the goal of reverse caching proxies is to have a centralized cached copy of the content, rather than distributing it in several browser caches.

Objects will be removed from the cache under the following conditions:

  • The TTL expires
  • The cache is full and objects have to be nuked in order to free up space
  • An explicit cache invalidation call is executed to remove select objects from the cache

And I guess that last option is what you need to ensure the Varnish cache is emptied.

In Varnish we call this purging. While purging is not part of the built-in VCL, the following tutorial explains which VCL code you need to perform these purges: https://www.varnish-software.com/developers/tutorials/purge/.

Alternatively, if you want to remove multiple objects from the cache at once, banning can be the solution. See https://www.varnish-software.com/developers/tutorials/ban/ for the corresponding tutorial.

Once you've set up a workflow to invalidate the Varnish cache, please tie this into your workflow for Memcached & Akamai. This will ensure consistent cache invalidation across the various caches.

Upvotes: 1

Related Questions