coderedcorp / wagtail-cache

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

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

Open davidu1975 opened 3 hours ago

davidu1975 commented 3 hours ago

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

vsalvino commented 2 hours 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.