1

I'm trying to use Views to randomly display an image(or node) from a content type. So everytime(or every 10secs) a user refresh their browser a new random image should display.

Here is my setting in Views. I added "Global: Random(asc)" in Sort Criteria, 1 item on Pager, and "Never Cache" Query results "10"seconds Rendered output on Caching setting. enter image description here
However, the page does not render a new image after 10sec browser refresh for Anonymous user, but any login user.

====== Update June 22, 2015 at 12:26pm ======

optional solution:
* exclude cache on specific page by using CacheExclude module
* still looking for solution to exclude cache on specific views(and view block) for anonymous users. Update: Found a solution for Views by using Views Random. This module allow user to enables cached views results randomly.

2 Answers 2

2

Pages are cached for anonymous users. Views obtains random image every time it has it's chance to work, but for anonymous your cache time is probably significantly longer.

All you have to do is to disable cache on the page you have this view on. How depends on the cache system you are using.

3
  • It works after I uncheck the "cache page for anonymous users". Thanks!
    – CocoSkin
    Jun 22, 2015 at 14:03
  • @CocoSkin Just don't leave it like that on production server. When your traffic is high, you definitely want to cache most pages. Look for a question about selective caching.
    – Mołot
    Jun 22, 2015 at 14:06
  • 1
    ya, the site has high traffic. I do need to turn "Cache pages for anonymous users" on and find a way not to cache on that View for anonymous
    – CocoSkin
    Jun 22, 2015 at 15:05
1

In the view, expand advance, locate Caching, set it to none enter image description here

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.

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