To replicate: turn on normal caching, set Splash to only appear once, log out, and view the front page twice.
What should happen: the splash should not appear on the second load.
What happens: Splash appears the second time around.

This is with thickbox, but it probably does the same thing with other splash types.

In Drupal 6, hook_init() is not called on cached pages. hook_boot() is. There needs to be a function that can clear the cache if we're on the page that the splash is set to appear on. If you've got the same problem, you can use this function until something better comes along:

function splash_boot() {
  // We can't cache the front page
  global $base_root;
  if (!function_exists('arg')) {
    drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
  }
	if ($_GET['q'] == drupal_get_normal_path(variable_get('site_frontpage', 'node'))) {
	  cache_clear_all($base_root . request_uri(), 'cache_page');
	}
}
CommentFileSizeAuthor
#18 splash-delete_cache-372333-18.patch841 bytesvenutip

Comments

RAFA3L’s picture

I have the same problem.

I already modify the module to make it to work on all pages using thickbox. The user can enter to the site using any url and the splash work perfect, but when the cache is "normal", the problem is there.

I'm experimenting with hook_boot() and hook_exit() without luck

Any idea?

seanr’s picture

How does this affect performance? Anyone used this in a production environment? I'd prefer to find a way around this that doesn't completely disable the cache for that page.

RAFA3L’s picture

Yes, would be nice found to keep the Splash module working even when the cache is active.

For now, the Splash doesn't work with cache.

Maybe the incidentist's idea work for the front_page or you can use http://drupal.org/project/cacheexclude. But I need the Splash module working in all pages to check if the user is over 18.

seanr’s picture

I looked into this some more and was just going to recommend that module. I really can't think of any other way to do this. There is no way to exclude a single module from caching, unfortunately. Drupal seems to want all or nothing.

Hobbes-2’s picture

subscribe

notabenem’s picture

+subscribe. Cache problem makes this unusable on high-capacity sites.

seanr’s picture

I'm at a loss here. If there are any cache experts out there, I need all the help I can get. We're obviously having the same problem but I can't figure out a fix and unfortunately, cacheexclude really isn't ideal when a site's homepage is the most commonly hit page.

cyberwolf’s picture

Subscribing.

awolfey’s picture

The init and boot fixes here work, but it seems like the way to do it is to have the checking happen clientside rather than serverside, or have the client make a call to the server to check.

bsztreha’s picture

subscribe, same problem...

sun.core’s picture

michaelgiaimo’s picture

Subscribe.

seanr’s picture

Did you try the new release posted on the 27th? That should have fixed it.

Rob_Feature’s picture

Priority: Normal » Critical

This is still an issue in the HEAD version as of today (december 7, 2011). Marking as critical..this makes splash unusable on sites where clearing the cache every time isn't an option (which should be, well, everyone :)

Rob_Feature’s picture

This is probably sort of a hack but it works. If you add the following at line 148 of splash.module (after it verifies that $splash is true), it won't cache the splash page load:

  /* dont cache this page 
    * from: http://us3.php.net/manual/en/function.header.php
  */
  header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
Rob_Feature’s picture

Status: Active » Needs review

If anyone wants to comment on what I did above (mostly to find out if it's appropriate) I'd be happy to roll a patch of this or something else. Marking this for review.

aze2010’s picture

subscribing

venutip’s picture

StatusFileSize
new841 bytes

The attached patch clears the cache for the front page (and only the front page) whenever it is visited, provided that Splash is turned on (that is, has a frequency other than 'Never (off)'). It makes use of hook_exit(), which makes Splash incompatible with aggressive caching, but I think this is acceptable since the whole reason hook_exit() exists is so it can be run on cached pages – exactly what we need in this situation.

Tested this with the Thickbox method of display, but should work for other methods.

Looking forward to feedback on whether this works for people (and ideas for other ways to fix the caching issue)!

rwinikates’s picture

Version: 6.x-2.3 » 6.x-2.8

I'm still having this issue even with version 6.2.8. Pressflow, caching turned off, works fine. Enabling page caching means that the user sees the splash page every time.

mail@victorquinn.com’s picture

Version: 6.x-2.8 » 6.x-2.9
Status: Needs review » Closed (fixed)

This issue is now fixed in version 6.x-2.9 of the Splash module.

A few notes though.

First, this disables caching on your frontpage. A necessary evil to deal with the fact that the splash module needs to be able to tell if a user has visited this site before and the only way to do that is to disable the cache there.

Second, you will need to go to admin/build/modules and hit the save button to make this work. In brief this is because the module uses hook_boot() which needs a refresh of the module cache in order to work. If you don't do this, Splash won't break caching or anything, but your visitors will be bombarded with the splash page each and every time they load the front page until you do this step.