Page cache

Discussion in 'HTML' started by philby, May 9, 2005.

  1. philby

    philby Guest

    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
    philby, May 9, 2005
    #1
    1. Advertising

  2. philby

    SpaceGirl Guest

    philby wrote:
    > 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.
    SpaceGirl, May 9, 2005
    #2
    1. Advertising

  3. philby

    Adrienne Guest

    Gazing into my crystal ball I observed "philby" <>
    writing in news:m0Jfe.7818$:

    > 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.
    --
    Adrienne Boswell
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
    Adrienne, May 9, 2005
    #3
  4. philby

    Toby Inkster Guest

    On Mon, 09 May 2005 13:50:26 +0100, philby <> wrote:

    > 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";

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


    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, May 9, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Nokes

    Cache::Cache Stale Segments

    Jeff Nokes, Sep 30, 2003, in forum: Perl
    Replies:
    0
    Views:
    549
    Jeff Nokes
    Sep 30, 2003
  2. DesignerX

    Page.Cache vs HttpContext.Current.Cache

    DesignerX, Jan 20, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    8,211
    vMike
    Jan 20, 2004
  3. =?Utf-8?B?b25l?=
    Replies:
    1
    Views:
    5,253
    Karl Seguin [MVP]
    Mar 8, 2006
  4. Sergey via DotNetMonster.com

    ASP.NET Cache vs Window System Cache

    Sergey via DotNetMonster.com, Nov 15, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    458
    Sergey via DotNetMonster.com
    Nov 15, 2006
  5. John
    Replies:
    2
    Views:
    1,165
Loading...

Share This Page