1

Drupal 7.

I run a site for a large publishing company. We're on Acquia Cloud, using Varnish to serve cached pages to anonymous users. Home page has a couple Views - one is a running list of news stories, and the other a Featured slider.

My minimum cache lifetime is set to 5 minutes, and Expiration of Cached pages to 15 minutes. On each View I have Content-based caching enabled.

I'd like to have new stories immediately shown on the home page. I believe I should only have to worry about the Varnish cache, that Content-based caching on the Views should be handling those caches, though to be honest I'm unsure of how to accurately test all this.

I read up on some things, and I found modules like Cache Expiration or Purge, and I think I'll also need to install Rules and maybe Cache Actions. I just figured I'd post here to see if someone else had experience with this and could offer some direction.

3

Install the varnish module and set the minimum cache lifetime to none at admin/config/development/performance Also be sure to add the tweaks to the settings.php from the varnish module page.

This should ensure that the cache is flushed when new content is added. You may want things to be a little more granular (if a complete cache clear at every content update would overload your server and cause performance problems) so using here are some other steps you can take:

I found a nice article about using varnish which you might consider checking out.

The author recommends:

  • Go to the Varnish settings page (admin/config/development/varnish) and select "None" under "Varnish Cache Clearing". This will make sure that all pages are not flushed when content is altered.
    • Enable the Cache actions and the Rules UI module
    • Go to Administration => Workflow => Rules and click "Create a new rule"
    • Select "After updating existing content" under "Node" as the reacting event
    • Add the "Clear a specific cache cid" action
    • Select cache_page as your cache bin.
    • Put "node/[node:nid]" in the value text area.

Try to edit one of your nodes, everything should still work. The difference now is that we are actually only purging the entry of the particular node that has been edited not the whole page. You can try this by visiting another node, notice that it is still cached by looking at the Varnish headers.

You will probably also want to clear the views cache (for your relevant views) so they are updated instantly. Testing should be relatively easy by adding new content in a browser and refreshing another browser window that isn't logged in. You should see your new content appear immediately at refresh.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.