I developed a block which depends on Drupal's new ip_address() function. It works well for authenticated users but not for anonimous.

It seams that it is global cached (even the BLOCK_NO_CACHE is set) for all anonymous visitors see the same content of that block (a country flag: their location). How the block caching for anonymous users works? How to develop a block which depends on time, ip addresses, languages to work for non-authenticated users?

Comments

yched’s picture

Is page caching enabled on your site ?
Most probably, it's not the cached *block* content that is reused for all users, but the cached *page* content...

he_who_shall_not_be_named’s picture

Status: Active » Closed (fixed)

Yep. As a conclusion such type of blocks won't work on caching enabled sites. I see.

Got it. Thank you!

he_who_shall_not_be_named’s picture

Status: Closed (fixed) » Active

Thank you for the answer.

There is a text at the 'normal caching' Normal (recommended for production sites, no side effects)

As you told me before, the normal caching overrides the block caching setting (BLOCK_NO_CACHE and for anonymous). As my opinion this is a serious side effect.

An anonymous user could see an other anonymous user's block content (could be ip, language, browser info, cookie, depends on what the developer puts on that block). This is also a security issue.

... or there is something I miss.

yched’s picture

Status: Active » Closed (works as designed)

This is the very definition of the page cache : The same content gets served to all anonymous users.
This is explained by the help text above the cache mode radios.

This is is no way related to blocks or block caching, it also holds for the page's main content.