Of HTML frames and caches

So there’s a website I’m in charge of which currently uses a simple two-frame design: A navigation frame on the left, and a content frame on the left. So 90s, I know. People who have the site bookmarked are most likely to have http://www.example.com bookmarked, which with the current implementation, points to index.html which provides the frameset, pointing to sidebar.php and main.php.

I’m ready to roll out the new version of the site, which doesn’t use frames at all. The index page in this case will be index.php. But the problem is, browsers love to cache the frameset pages, which is a big problem since sidebar.php got moved and main.php isn’t supposed to exist anymore. So a big chunk of users would get two 404s at once and get massively confused, even though a simple skip-cache-refresh solves the problem (but I can’t assume that they’d know this).

At the moment, the best I can do is have main.php be a page telling the visitor, “Hey, your idiot browser cached a frameset that’s defunct now, here’s how to tell your browser to skip the cache and reload.” Alternatively, I can put this JavaScript in main.php:


if(top !== self)
     top.location.replace(self.location.href);
window.location = 'index.php';

That does a successful redirect, but every time my lovely cached visitors go to www.example.com, they’ll keep performing that redirect until their browser decides to drop the frameset page from their cache, which causes two HTTP GETs per visit, a delay in getting to what they want, and is in general a suboptimal solution to the problem.

Is there any way, through a combination of HTML, JavaScript, and PHP, that I can tell the browser to drop the frameset page from its cache and actually do a “GET /” from the server, without having to tell the user to do it manually?

Is your server Apache? If so, you can do a 301 redirect in the .htaccess file.

You can use the 301 redirect as ZipperJJ suggests. You can use the JavaScript script you listed. You can add in a no cache attribute with your new pages for a while. You can have a temporary banner atop all of your pages informing web users things have changed.

But no matter what you do, how effective your bandaids may be, many, many, many [del]web[/del] [del]Internet[/del] computer users are idiots.

Do what you can and be prepared for complaints.

I don’t understand why you have a problem at all, assuming that www.example.com will now default to your new index.php file, which never existed. So if this is the case, what would cause a browser to try to fetch anything from cache? It’s never heard of http://www.example.com/index.php. Am I missing something?

Something’s a bit sinister here.

Those with browsers that cached the page would go to example.com, and their browser wouldn’t even do a “GET /” (which, yes, would point to index.php), it’d just load up the frameset page and get the stuff contained therein. I had this identical problem on a different website last year, so at least I see it coming this time around.

Oh, and I didn’t mention, I work for a university. So the intended audience here is a bunch of people with doctorates. You might think that would make it somewhat easier, but in actuality, it makes it ten times worse.

To ZipperJJ: Yes, it’s Apache, but no, that doesn’t work. And it’s a Linux server, and I’ve already made a symlink pointing to index.php, but that doesn’t solve the problem either. The browsers which cached this index.html aren’t even going to request it from the server; they just assume it’s there and hasn’t changed. Which is why I’m going crazy trying this JavaScript madness.

Hmm, maybe I’m slow … but if the homepage is so solidly cached that you don’t even get a GET /, how is any change you make ever going to make a difference? They never do the GET to get your fancy new javascript. In fact, they don’t even need your server at all. :confused:

The page containing the frameset gets cached. The two pages the frameset points to are not cached.

That’s kind of odd that the homepage is cached but the individual frames aren’t – are both frames cached, or does sometimes one gets cached and not the other?

In any case, instead of doing the redirect using .htaccess, can you redirect using a RedirectMatch directive in the apache config, and only redirect if leftnav.php (or whatever) is requested?

Otherwise, just do the javascript thing that you already have. I don’t think there’s any magic 100% clean method to do what you want.

This sounds like you’re assuming things that used to be true, a decade or more ago, but aren’t true any longer. And frankly, even if it is true, it’s nothing to worry about.

As far as I can see, if they get a 404, they can hit F5 and refresh, or just revisit later, and it will all sort itself out.

If it doesn’t, forget 'em.