coderedcorp / wagtail-cache

A simple page cache for Wagtail based on the Django cache middleware.
Other
87 stars 29 forks source link

Is there a way of stopping 302/301 and 404s being cached? #78

Closed davidu1975 closed 1 month ago

davidu1975 commented 1 month ago

Is there a way of stopping 302/301 and 404s being cached? automatically

vsalvino commented 1 month ago

Yes, use the is_response_cacheable hook. Check request.status and return False. https://docs.coderedcorp.com/wagtail-cache/getting_started/hooks.html

Side note, I'd highly recommend caching 404s as those are very frequent (e.g. bots probing for WordPress URLs) and they are taxing on the database.