4

Faced with a strange situation: if a View uses filter "Post date" (or similar) with an offset (eg, "> = -1 month"), this View won't cache.

Example: I create a simple View with Block display.

  • Field: "Content: Title"
  • Caching: "Time-based | 1 hour/1 hour"
  • Block caching: "Cache once for everything (global)"

Of course, global setting "Cache blocks" is on.

If I place this block on a page, it is cached properly.

I want to filter nodes for a certain period of time. I add filter with an offset from the current time: "Content: Post date (>= -1 month)". And this block will no longer be cached! Every time I load a page with this block, there is a new call to the database ("SELECT node.title AS node_title ..."). In addition, the table "cache_views_data" is filling with multiple records like "my_view:block_1:results:1a2s3d4d" and "my_view:block_1:output:m0n9b8v7".

How could I force caching of this block to work?

  • Remind me, can you set granularity on post date filter? – Mołot Dec 15 '14 at 22:09
  • No. Granularity is on sort only. – Rdnala Dec 15 '14 at 22:29
  • Too bad. With granularity larger than one hour it should work. I suspect cache is auto-off due to time-based filter. How far outside Views and maybe even Drupal are you willing to go for solution? Because I don't know how to fix views (and if that's what you want, maybe you should file a bugreport), but I believe I know ways around it. – Mołot Dec 15 '14 at 22:34
  • I'd like to stay inside Drupal, if it is possible. :) – Rdnala Dec 15 '14 at 22:39
  • So I wish you good luck and go to get my sleep. Now I don't have anything like answer. – Mołot Dec 15 '14 at 22:41
0

In Drupal caching system, there's an option to cache pages/blocks for anonymous users only, maybe it's the same thing for Views. Check if it works with a not logged in user.

0

Finally, I found a particular workaround here.

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.