Posted by incidentist on February 10, 2009 at 8:17pm
| Project: | Splash |
| Version: | 6.x-2.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
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:
<?php
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');
}
}
?>
Comments
#1
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?
#2
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.
#3
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.
#4
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.
#5
subscribe
#6
+subscribe. Cache problem makes this unusable on high-capacity sites.
#7
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.
#8
Subscribing.
#9
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.
#10
subscribe, same problem...
#11
#12
Subscribe.
#13
Did you try the new release posted on the 27th? That should have fixed it.
#14
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 :)
#15
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
#16
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.
#17
subscribing
#18
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)!