Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: ms_ukyankee on May 02, 2005, 11:10:20 AM

Title: Enable caching of search pages
Post by: ms_ukyankee on May 02, 2005, 11:10:20 AM
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
Title: Re: Enable caching of search pages
Post by: [Unknown] on May 02, 2005, 02:20:21 PM
That only has effect if you have "allow browsers to go back to cached pages" off.

-[Unknown]
Title: Re: Enable caching of search pages
Post by: ms_ukyankee on May 02, 2005, 06:12:31 PM
[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
Title: Re: Enable caching of search pages
Post by: [Unknown] on May 02, 2005, 07:01:18 PM
Use:

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

Instead.

-[Unknown]
Title: Re: Enable caching of search pages
Post by: ms_ukyankee on May 02, 2005, 08:36:27 PM
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
Title: Re: Enable caching of search pages
Post by: [Unknown] on May 02, 2005, 10:35:47 PM
Can you post 4 lines above and below the line in the error message?

-[Unknown]
Title: Re: Enable caching of search pages
Post by: ms_ukyankee on May 03, 2005, 03:06:00 AM
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. :)