UBB.Dev
Mod Name / Version: Allow Visited Pages To Be Cached By Browser

Description: Some hosts use an HTTP header which prevents already visited forum pages from being cached by your browser.

Thus, when you use the back/forward browser buttons, you will need to reload every single page fresh again, which greatly slows down forum browsing for dial-up users when jumping in and out of threads, as well as increases bandwidth usage.

This mod will allow you to override their HTTP header with your own, which does permit caching.

All clicked on links will still always load fresh - that functionality won't be affected whatsoever. This way the *user* can decide if they wish to draw from their cache or reload from the server.

Many hosts already use the following configuration by default, but for those that don't (eRoute for example), here's the fix...



Working Under: UBB.Threads 6.2-6.3-6.4-6.5

Mod Status: Finished

Any pre-requisites: none

Author(s): Twisty

Date: 11/27/03

Credits: none

Files Altered: templates/default/ubbt_header.tmpl

New Files: none

Database Altered: no

Info/Instructions:


Change ubbt_header.tmpl

FROM THIS:


Code
<? //UBBTREMARK <br />echo <<<UBBTPRINT <br /><!-- START OF header.tmpl TEMPLATE --> <br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br /><html dir="{$ubbt_lang['READ_DIRECTION']}"> <br /><head> <br />$headerinsert <br />$refresh <br /><meta http-equiv="Content-Type" content="text/html; charset={$ubbt_lang['CHARSET']}" /> <br /><link rel="stylesheet" href="$stylesheet" type="text/css" /> <br /><link rel="shortcut icon" href="{$config['images']}/favicon.ico" /> <br />$javascript <br /><title>{$config['title']}: $inputTitle</title> <br /></head> <br /><body> <br /><!-- END OF header.tmpl TEMPLATE --> <br />UBBTPRINT <br />/* UBBTREMARK */ ?>



TO THIS:


Code
<? //UBBTREMARK <br />header("Pragma: private"); <br />header("Expires: 0"); <br />header("Cache-Control: private, post-check=0, pre-check=0"); <br />echo <<<UBBTPRINT <br /><!-- START OF header.tmpl TEMPLATE --> <br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br /><html dir="{$ubbt_lang['READ_DIRECTION']}"> <br /><head> <br />$headerinsert <br />$refresh <br /><meta http-equiv="Content-Type" content="text/html; charset={$ubbt_lang['CHARSET']}" /> <br /><link rel="stylesheet" href="$stylesheet" type="text/css" /> <br /><link rel="shortcut icon" href="{$config['images']}/favicon.ico" /> <br />$javascript <br /><title>{$config['title']}: $inputTitle</title> <br /></head> <br /><body> <br /><!-- END OF header.tmpl TEMPLATE --> <br />UBBTPRINT <br />/* UBBTREMARK */ ?>


:-)

Disclaimer: Please backup every file that you intend to modify.
If the modification modifies the database, it's a good idea to backup your database before doing so.

Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop.If you need official support, you'll need to restore unmodified files.
This also works for 6.5.
Can someone modify the initial post?
Thanks for verifying. Done.
Is there a way to find out if your host uses an HTTP header which prevents already visited forum pages from being cached?
[]DLWebmaestro said:
Is there a way to find out if your host uses an HTTP header which prevents already visited forum pages from being cached? [/]

Indeed there is. Upload this page to your ubbthreads folder (well it can go anywhere, but is most convenient there imo) and then open it in your browser.

Now notice the section where it says "Cache-Control" & "Pragma" and report back the configuration.

My server uses this (which *doesn't* cache PHP pages)...

------------------------------------------------------------
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache
------------------------------------------------------------

But regardless of what it's already set at, it won't do any harm at all to change the threads header to whatever you want as that will supercede the server header no matter what it currently is.
I already had an info.php file loaded.

The only listing mentioning cache is:
[]
session.cache_expire 180 180
session.cache_limiter nocache nocache
[/]

The word "pragma" does not exist.
Well an easy way to tell is by simply looking in your browser cache to see if any forum pages are found there

With yours, it is already caching them so you have nothing to worry about.
I was just wondering, when using this, and returning to a forum that's been cached, doesn't this mess up marked read display until the user refreshes the page? As well as new posts that they've added not showing up until the thread is refreshes, etc
[]RandyJG said:
I was just wondering, when using this, and returning to a forum that's been cached, doesn't this mess up marked read display until the user refreshes the page? As well as new posts that they've added not showing up until the thread is refreshes, etc [/]

I think I explained it pretty well in my initial post. All links (ie. forum navigation links) will still load pages fresh which is an important point, but the browser <- -> buttons will draw from the cache (which as you say won't be updated until refreshed). Thus the user decides which method they wish to use.

This way those on dialup can refresh occassionally as needed instead of constantly which is much slower.

Incidentally, the functionality with this enabled will be identical to the way the threadsdev forum functions right now, because it caches pages too.
© UBB.Developers