XF 2.1 How to prevent page from being cached?

Kirby

Well-known member
I've got a widget on the public sidebar. If this widget does display certain data, the page may not be cached for guest page cache.

How can this be achieved in a clean & scalable way?

The only approaches I've found so far are
  • Abuse the dbWriteForces cookie
    Feels hacky
  • Use the onSetup closure
    This does not seem to be a scalable approach that would work for multiple Add-ons (from multiple authors)
 
Last edited:
Set:
Code:
\XF\Pub\App::$allowPageCache = false;
We use this in several controllers to disable caching in them entirely (registration most significantly), but potentially also if you have a page criteria check whether the user has come from a search engine (and it's true).
 
Top Bottom