News:

Wondering if this will always be free?  See why free is better.

Main Menu

Enable caching of search pages

Started by ms_ukyankee, May 02, 2005, 11:10:20 AM

Previous topic - Next topic

ms_ukyankee

In Sources/Load.php

Find
// Change it so the cache settings are a little looser than default.
if (!empty($modSettings['databaseSession_loose']))
header('Cache-Control: private');
}


Replace with
// Change it so the cache settings are a little looser than default.
if (!empty($modSettings['databaseSession_loose']) || (isset($_REQUEST['action']) && ($_REQUEST['action']=='search' || $_REQUEST['action']=='search2')))
header('Cache-Control: private');
}


This will allow browsers to cache the search pages when caching is disabled in Settings, so that people are not getting page expired messages when using the Back button while searching. Hope that helps someone else who wants it cached. :)

Edit: modified with corrected code posted by [Unknown] to fix bug with SSI
SMF since 2004 <3

[Unknown]

That only has effect if you have "allow browsers to go back to cached pages" off.

-[Unknown]

ms_ukyankee

[Unknown], I now see this is causing an error in pages using SSI.php.  :-[ Any way to fix it?

QuoteNotice: Undefined index: action in /home/site/public_html/smf/Sources/Load.php on line 1138
SMF since 2004 <3

[Unknown]

Use:

if (!empty($modSettings['databaseSession_loose']) || (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'search' || $_REQUEST['action'] == 'search2')))

Instead.

-[Unknown]

ms_ukyankee

Thanks [Unknown], it almost works. It's still giving me crap though. I changed the code on a second forum on the same site first to test with less traffic though it was v1.0.2 and it worked fine, but when pasting the identical line into the one with the SSI problem, which is v1.0.1, it gives me a parse error and I can't work out why. It's identical, the only difference is the forum version, and templates, no packages installed. ???

QuoteParse error: parse error, unexpected T_STRING in /home/site/public_html/smf/Sources/Load.php on line 1139
SMF since 2004 <3

[Unknown]

Can you post 4 lines above and below the line in the error message?

-[Unknown]

ms_ukyankee

#6
Nevermind, I'm a dork. I didn't have the parentheses right, it's all fixed now, but it's weird that it worked on one and not the other. Thanks. :)
SMF since 2004 <3

Advertisement: