How can I have Discourse query my cache server with the PURGE request when its content is updated?
Our server has a ton of RAM, so I run all my sties behind a varnish cache, which means that >80% of the queries that come to our sites never actually have to trigger any backend calls (no executing of server-side code, no need to make sql queries, etc). So >80% of our requests are super-fast and just returned from RAM.
I’d like to do this for our Discourse site as well. Most queries of a user reading around in our threads are read-only, and there’s no reason to bother Discourse at all for this activity; these requests should just be returned to the client directly from RAM by varnish without querying the Discourse backend at all.
Obviously the cache needs to be notified when the content for a given page changes so the next request for that page will actually call the backend–then subsequent requests for that page are returned from cache until the cache object expires (for us after 24-hours) or it’s PURGEd by a call from the application (ie: Wordpress, MediaWiki, Discourse, etc).
This is all pretty standard for web applications. For example, making PURGE calls when an article changes is built directly into MediaWiki:
And there’s lots of plugins for doing this in Wordpress. Personally, we use Razvan Stanga’s ‘vaching’ plugin:
So how can this be achieved with Discourse? How can Discourse be configured so that it sends PURGE requests to our defined cache servers when a change takes place to one of its pages (ie: a new post in a thread, an edit to an existing post, a user’s bio changes, etc)?