When my members login they are taken to welcomeBack.php. This page spawns a lightbox to show a marketing message, if it’s determined that this member needs to see it. Once they read the message, and indicate their response, it’s recorded in the database, the session variable $shownCampaign is set to Yes, and then they are redirected to another page where they are given a chance to see the upgrade features that are available.
What is happening now is that some of my members are clicking their browser back button at this point, when takes them back to welcomeBack.php and the lightbox is spawned again. Then they indicate their response and it’s recorded in the database again. I think welcomeBack.php is being cached or something. When testing out this problem I would:
Login to the test server
Be shown the lightbox with marketing message
Indicate my answer and be redirected to the upgrade features page
Edit welcomeBack.php and remove the code that launches the lightbox
Save welcomeBack.php and upload to the test server
Click the browser’s back button
Be returned to welcomeBack.php and the lightbox spawns, even though I removed to code for it
This is why I think welcomeBack.php is being cached. But I have the following code at the very top of welcomeBack.php, so I’m not sure what is happening:
header(“Cache-Control: no-cache, must-revalidate”); // HTTP/1.1
header(“Expires: Sat, 26 Jul 1997 05:00:00 GMT”); // Date in the past
My members are experiencing this in production, and I’m duplicating and testing possible fixes on the test server. So this is a bit more complicated than just clearing my browser cache. Thanks though.
Wow, this code actually worked in Safari for me, but not Chrome. Why can’t web browsers come to an agreement on some basic standards. Any suggested work arounds?
Hmmm…do you have a recent version of Safari installed? I had a similar problem a while back, and Chrome and Safari gave me issues. I thought Chrome resolved this, but obviously not…
As for a workaround for Chrome, I’m honestly at a loss. I don’t think there’s much you can do about it without some javascript hacking (maybe the JS whizzes here can come up with a solution; I’m not very strong in it ).
Just a heads up while you try to figure out a solution for Chrome:
Do not convert the above PHP headers to it’s html equivalents ( using meta tags ); not all browsers will parse them correctly, if at all – big surprise huh?
I’m surprised the header stuff arout77 posted doesn’t work fully. Anyway, another idea: to force caching not to kick in give the page a random new name, probably using a query string would do it. welcomeBack.php?876dfjkhsj, welcomeBack.php?678sdk, welcomeBack.php?768kjhfg etc.