3

Our site uses Views heavily and unfortunately we've got a caching problem.

On our front page we've got a View that only shows content whose publishing date is more recent than the current date. So if we post an article whose publishing date is 2 hours from now, it should be visible in two hours from now on.

This works fine for logged in users. But the majority of our visitors doesn't have an account. And when not logged in the article gets published seemingly at random. It could be visible 20 minutes or 1 hour past the desired date.

The View has got no caching enabled. Site wide we've got the following options enabled:

  • Caching mode: normal
  • Page compression
  • Block caching
  • CSS caching
  • JavaScript caching

Do you have some hints regarding our problem? I'm using Drupal 6.

6 Answers 6

0

Reposted a new answer to suggest maybe using scheduler module to set the desired publish date for individual nodes.

Content will be published automagically on your specified date. Works great.

  • You can also use workflow, rules and actions to achieve same function, albeit with more overhead.
1

Here is a small hack to prevent some pages from being cached for anonymous users:

// Prevents frontpage caching
if (drupal_is_front_page()) {
  $GLOBALS['conf']['cache'] = FALSE;
}

Hope this helps, cheers!

3
  • Do you think that deactivating the caching of pages site-wide would solve me problem?
    – user6966
    Apr 23, 2012 at 18:46
  • Your question was saying front-page only. COde above disables caching for front-page only. But, if this does not work, views caching is not handled by core so you may need to tweak views caching option, see this thread: drupal.stackexchange.com/questions/22724/… Apr 23, 2012 at 19:23
  • Your right, my question concerned just the front page, but I was also curious about all pages in general.
    – user6966
    Apr 23, 2012 at 20:03
1

The problem is that the content not appearing is unpublished, which Drupal will hide until it is published.

You can circumvent this in two ways:

  1. In Views make sure there is no filter for "Content: Published (Yes)". If there isn't one, then you can also disable Node Access checks. Under Advanced > Other > Query options, check Disable SQL Rewriting.
  2. Install the "View Unpublished" module, and allow Anonymous users to view the unpublished content.

And I would leave your cache the way it is currently, will greatly help site performance and stability under load.

3
  • @Bernard I think Jonathan has better answer, I was looking into caching issue but re-reading his post, it makes sense. As an alternative to letting anon users view unpublished content, I have installed workflows where posts were linked to an action & rule that would publish node only on certain date/time. Apr 23, 2012 at 19:33
  • The content is marked as published, the check box is ticked. It's only that the publication date is in the future. Does that really make a difference for Drupal?
    – user6966
    Apr 23, 2012 at 20:05
  • @Bernard - Not really sure, the way I usually implement this feature is by setting the published in a future date, using scheduler module. Apr 23, 2012 at 20:22
0

I've deactivated the page cache now (setting caching mode to deactivated) and this solved my problem.

As written in the description, the page cache affects pages called by guests (i. e. not authenticated users). Since I don't want those pages to be cashed, I've deactivated this feature.

I hope that the performance won't suffer that much.

1
  • 1
    Depending on the traffic the site receives, it may not make a difference but be aware caching reduces your apps response time considerably, I would of tried a cache-friendly option. Caching is only important if you want your application to be responsive. If you don't mind waiting a few seconds on each page load, your solution will work. Also be aware .. the usual convention is to use the 'published' field as the 'flag' to tell if page is displayed or not. You are over-riding this built-in native convention with your own, using a custom query. This can work fine, it's just not 'Drupal' way. Apr 23, 2012 at 22:40
0

Not sure, if this is what your looking for Views Content cache. But its worth a check out.

0

If your looking to dive deep into boost configuration it will handle this use case fairly well. We have the same issue at work. I don't have the time to help you set it up though. http://drupal.org/node/784676

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.