Page cache

P

philby

I have an asp web page which gives the result of a search, and then you
click on links from it to go to linked pages in the same window (ie not
opening new windows). This is essentially the way most search engine sites
work. The problem I have it that when you go back to the results page the
(lengthy) search happens again because the page is not in the browser cache
(or the browser thinks it has to re-load it from the server and so it
ignores the cache).

I have looked up lots of (quite confusing) web sites about using http
headers and meta tags to force a page to ignore the local cache and reload
from the server, but I need to force it to USE the cache. How do I do this?

Philby
 
S

SpaceGirl

philby said:
I have an asp web page which gives the result of a search, and then you
click on links from it to go to linked pages in the same window (ie not
opening new windows). This is essentially the way most search engine sites
work. The problem I have it that when you go back to the results page the
(lengthy) search happens again because the page is not in the browser cache
(or the browser thinks it has to re-load it from the server and so it
ignores the cache).

I have looked up lots of (quite confusing) web sites about using http
headers and meta tags to force a page to ignore the local cache and reload
from the server, but I need to force it to USE the cache. How do I do this?

Philby

You cannot FORCE a browser to do ANYTHING.
 
A

Adrienne

I have an asp web page which gives the result of a search, and then you
click on links from it to go to linked pages in the same window (ie not
opening new windows). This is essentially the way most search engine
sites work. The problem I have it that when you go back to the results
page the (lengthy) search happens again because the page is not in the
browser cache (or the browser thinks it has to re-load it from the
server and so it ignores the cache).

I have looked up lots of (quite confusing) web sites about using http
headers and meta tags to force a page to ignore the local cache and
reload from the server, but I need to force it to USE the cache. How
do I do this?

Philby

I don't think this is a client side issue at all, this has something to do
with the way you are running your script.

If you have something like:
*** Search page ***
<% dim keyword
keyword = request.querystring("keyword")

sql = "SELECT results FROM table WHERE filter = " & keyword
set rs = createobject("ADODB.Recordset")
rs.Open sql, connectionstring
%>
<form method="get" action="<%=request.servervariables("script_name")%>">
<p><input type="text" name="keyword" value="<%=keyword%>"> <input
type="submit" value="Search"></p></form>

<% if rs.EOF then%>
<p>No results found</p>
<% else
while not rs.EOF
....%>
--- results ---
<a href="results.asp?keyword=<%=keyword%>">Result</a>
<% rs.Movenext
wend
rs.Close
set rs = nothing
set connection = nothing
end if
%>
*** Results page ***
<% dim keyword
keyword = request.querystring("keyword")
%>
<a href="searchpage.asp?keyword=<%=keyword%>">Back to search page</a>

That will let you keep the keyword across pages and return the visitor to
the results originally found. The user can then put in other keyword(s) as
needed.
 
T

Toby Inkster

I have looked up lots of (quite confusing) web sites about using http
headers and meta tags to force a page to ignore the local cache and
reload from the server, but I need to force it to USE the cache. Howdo
I do this?

Firstly, understand that you CANNOT force the client to do anything. But
you may suggest that it uses the cache. In general, using the cache when
the back button is hit is the default behaviour, so you don't need to do
anything -- just avoid sending any cache control headers at all!

If you're still finding that browsers are constantly reloading the search
results, you can cheat using sessions to store the results. Here's an
example using PHP:

======================= search.php =======================
<?

session_start();

// $q is their search query
$q = $_GET['q'];

// header.php uses the variable $title to print a nice heading
$title = "Search for $q";
include "header.php";

// if the user has performed this search before
if (isset($_SESSION['searches'][$q]))
{
print $_SESSION['searches'][$q];
}

// otherwise
else
{
// some kind of function to read results from DB
$results = get_search_results_from_db($q);
// some kind of function to format them nicely
$prettyresults = format_results($results);
$_SESSION['searches'][$q] = $prettyresults;
print $prettyresults;
}

// boring copyright info
include "footer.php";

?>
==========================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top