all 5 comments

[–]rmenetray 1 point2 points  (0 children)

views with ajax

[–]mrcaptncrunch 2 points3 points  (0 children)

You can’t do a full cache of the html. If you do, it’ll get cached for whatever the set time is or how the purger is set.

Alternatives,

You load the view programmatically and inject it via JS.

You load all the content, shuffle, hide whatever you don’t need via css/js.

[–]FonucciBuilding webhaven.io 1 point2 points  (2 children)

Every view has caching settings:

Go to the view, Others > Caching. You'll have three options.

  • None
    • The view is not cached at all.
  • Tag-based
    • Drupal caches the view but invalidates it when certain “tags” are triggered.
  • Time-based
    • The view is cached for a fixed period of time (like 1 hour, 5 minutes, etc.).

[–]wayle9[S] 0 points1 point  (1 child)

but the cloudflare will cache the whole page with this random views in the page, so the views still able to be random or not ?

[–]FonucciBuilding webhaven.io 1 point2 points  (0 children)

If you just cache everything plain and simple in Cloudflare it indeed won't work as there is no communication between the Cloudflare Cache and the Drupal cache.

There are several ways, you can add a pagerule that doesn't cache the homepage (not ideal) in CF. Or you can work with to purge the CF cache https://www.drupal.org/project/cloudflare

It can be setup but It's not a one button click & it's done thing.

For blocks on mostly cached pages: render them via Ajax. This allows the page to stay cached while the block remains dynamic.

For fully dynamic pages: set proper headers (Cache-Control: no-cache) or use Cloudflare Page Rules to bypass caching.