ministryofjustice / justice-gov-uk

Justice UK website
https://www.justice.gov.uk/
MIT License
2 stars 0 forks source link

Purge cache - doesn't refresh after content updated #147

Open wilson1000 opened 4 months ago

wilson1000 commented 4 months ago

It would be nice if we can purge the cache after content updates are made by editors.

Suggestion Using the URL pattern defined in the server.conf Nginx file, we can target the pretty permalink of the content that has been updated.

Example If the content had a permalink of:

https://www.justice.gov.uk/courts/procedure-rules

... immediately after content has been updated or successfully published, either from a revision or schedule, we send a GET request to:

https://www.justice.gov.uk/purge-cache/courts/procedure-rules

The result would be instant, allowing content to be available to site users when intended.

wilson1000 commented 4 months ago

Caveat Testing has revealed that some hits on purge-cache resulted in 412 Precondition Failed.

This is due to the load balancer selecting different pods, ones that have not had the cache set. In production caching will not be affected, however, this does mean that this issue will need a clearing policy that extends to accept that some attempts to clear all will not be successful

Response codes 412 = failed attempt 200 = successfully purged