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:qwe123" and "my_view:block_1:output:rty456".

Is there a way to force caching of this block to work?

Comments

matysek145’s picture

I suppose it won't cache, beacuse every query is unique - thanks to date offset filter. On every request, query differs by date timestamp so it does not hit the cache.
In order to cache the queries, you could somehow round the timestamp to current hour and then filter by date.

MegaChriz’s picture