Problem/Motivation

When the anonymous page cache is enabled (or Memcache module is enabled and $conf['page_cache_without_database'] = TRUE; in settings.php), a message isn't showing for anonymous users. The reason for it is /conditional_message_data_output returns nothing. That's is because the page is taken from the cache entirely.

And what do we put into the page cache?

$url = url('conditional_message_data_output', array('absolute' => TRUE));
cache_set($url, $data, 'cache_page');

It's an array instead of rendered content. And even if we render it, we still need to set the proper headers (eg content-type), right now the defaults are returned.

Comments

SAVEL created an issue. See original summary.

savel’s picture

Title: Caching work incorrectly » Caching works incorrectly
savel’s picture

Here is the simple patch that fixes the issue.

savel’s picture

Status: Active » Needs review
StatusFileSize
new2.51 KB

I've created a more advanced patch that fixes full-page caching for anonymous users.

nikolas.tatianenko’s picture

Status: Needs review » Reviewed & tested by the community

Works as expected!

savel’s picture

Status: Reviewed & tested by the community » Needs work

I've found a couple of notices with the latest patch. There's nothing serious but flooding at dev's logs. I will fix and return.

savel’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Needs work » Needs review
StatusFileSize
new2.55 KB
new401 bytes

Here is the patch. Slightly updated #4 by adding two default values to the cached array.

nikolas.tatianenko’s picture

Status: Needs review » Reviewed & tested by the community

Works as expected.

savel’s picture

Issue summary: View changes
savel’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.38 KB

7.x-1.x-dev was updated so the patch #7 no longer applies.

Rerolled against the latest dev.

nikolas.tatianenko’s picture

Status: Needs review » Reviewed & tested by the community

  • SAVEL committed 88f7100 on 7.x-1.x
    Issue #3106550 by SAVEL, nikolas.tatianenko: Caching works incorrectly
    
savel’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x-1.x. Thank you!

savel’s picture

Status: Fixed » Closed (fixed)