开发者

Drupal 6 - Disable Views cache for specific View

I have lots of views which don't change very often, and enjoy the ben开发者_开发技巧efit of caching. But I have 1 view which is used to display a random quote in a block in my sidebar, which I do not want cached. Is there a way to disable caching for this particular view? Specifically, I want to see a different quote every time I refresh the page.

UPDATE: I have Caching Mode set to Normal in my site's Performance settings, and I've tried going into the View and setting Caching = None (as well as in Block settings: Caching = Do not cache), and going into the Views tools page, and selecting "Disable views data caching", and it works when I'm logged in, but as soon as I logout, the quote stays the same after refreshing.

UPDATE: I'm beginning to think that if you have enabled page caching in Drupal, then all other cache settings are ignored (i.e. View and Block caching). Can anyone confirm this?


In the Views UI under the Basic settings of a particular display you have an option called Caching make that as none. And your view won't be cached. So you get random quote everytime. :)

EDIT : Oops how did I miss what you were telling :(

Use Cache Exclude module to disable caching on the particular page. If your random block is on many pages, you may need to dig deeper to find an alternate solutions. All the best ;)


Suggestion: Randomize on the client side. Load 'em all up into a javascript array and write a quick function to select the random quote on page load. Unless there are hundreds of possible quotes it shouldn't weigh the page down too much, & you could exclude this one little sidebar feature from consideration when working on your caching strategy.

In fact even if there are hundreds of random quotes, you could use a combination of the two approaches. Grab 50 random lines w/ your module and them let javascript pick from there. To an end user it would be nearly identical.


The block may be being cached. Did you try to http://drupal.org/project/blockcache_alter ?

You can also directly change a block's cache setting in the database with something like:

update blocks set cache=-1 where bid=<blockbid>;

Setting this cache entry to -1 means the block will not be cached.

In addition, setting cache to 1 will cache the block per role, 2 will cache the block per user, 4 will cache the block per page, and 8 will cache the block exactly once (the same for all users, pages, etc).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜