Advertisement:

Author Topic: Enable caching of search pages  (Read 19551 times)

Offline ms_ukyankee

  • Full Member
  • ***
  • Posts: 529
  • Gender: Female
Enable caching of search pages
« on: May 02, 2005, 11:10:20 AM »
In Sources/Load.php

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

Replace with
Code: [Select]
// 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
« Last Edit: May 03, 2005, 04:46:19 AM by leah »
SMF since 2004 <3

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Enable caching of search pages
« Reply #1 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]

Offline ms_ukyankee

  • Full Member
  • ***
  • Posts: 529
  • Gender: Female
Re: Enable caching of search pages
« Reply #2 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?

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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Enable caching of search pages
« Reply #3 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]

Offline ms_ukyankee

  • Full Member
  • ***
  • Posts: 529
  • Gender: Female
Re: Enable caching of search pages
« Reply #4 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. ???

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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Enable caching of search pages
« Reply #5 on: May 02, 2005, 10:35:47 PM »
Can you post 4 lines above and below the line in the error message?

-[Unknown]

Offline ms_ukyankee

  • Full Member
  • ***
  • Posts: 529
  • Gender: Female
Re: Enable caching of search pages
« Reply #6 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. :)
« Last Edit: May 03, 2005, 03:16:05 AM by leah »
SMF since 2004 <3