Caching

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shabam

    #1

    Caching

    I need to implement a caching mechanism for my script URLs. Instead of
    www.domain.com/script.cgi?id=1234 , which the browser will obviously not
    cache, I want the URL to be something like www.domain.com/1234 or
    www.domain.com/1234.htm instead. This way the browser will cache the page.

    I have two concerns:

    1) Is this possible without rewriting the url? If so how?

    2) The result page will be different for different users. Will this cause
    trouble with proxy servers? My goal is only to cache a particular version
    for a particular user so that if he requests the URL again (within X
    minutes) the server doesn't have to process it again.


  • Chung Leong

    #2
    Re: Caching

    Caching has nothing to the appearance of the URL. It depends on HTTP headers
    that you send to the browser.

    See http://www.w3.org/Protocols/rfc2616/...4.html#sec14.9
    and http://www.php.net/manual/en/function.header.php.

    You can flag a page as private so that a shared proxy wouldn't save it.

    Uzytkownik "Shabam" <info@pcconnect .net> napisal w wiadomosci
    news:C6OdnRrDgr EVRdvdRVn-hw@adelphia.com ...[color=blue]
    > I need to implement a caching mechanism for my script URLs. Instead of
    > www.domain.com/script.cgi?id=1234 , which the browser will obviously not
    > cache, I want the URL to be something like www.domain.com/1234 or
    > www.domain.com/1234.htm instead. This way the browser will cache the[/color]
    page.[color=blue]
    >
    > I have two concerns:
    >
    > 1) Is this possible without rewriting the url? If so how?
    >
    > 2) The result page will be different for different users. Will this cause
    > trouble with proxy servers? My goal is only to cache a particular version
    > for a particular user so that if he requests the URL again (within X
    > minutes) the server doesn't have to process it again.
    >
    >[/color]


    Comment

    • William Ahern

      #3
      Re: Caching

      Shabam <info@pcconnect .net> wrote:[color=blue]
      > I need to implement a caching mechanism for my script URLs. Instead of
      > www.domain.com/script.cgi?id=1234 , which the browser will obviously not
      > cache, I want the URL to be something like www.domain.com/1234 or
      > www.domain.com/1234.htm instead. This way the browser will cache the page.[/color]

      As another poster stated, generally caching has nothing to do w/
      the URL.

      That said, a long time ago some search engines did not follow URLs w/ query
      string components (since it's harder to judge useless page recursion).
      So...

      At least with apache, if I have the URL:

      http://www.domain.com/path/to/script.html?nam=val

      I could call that script w/ the URL:

      http://www.domain.com/path/to/script.html/nam/val

      Of course, the path would have to be translated in the script in order
      to get the nam=val pair again. In PHP you could use:

      if (getenv('PATH_I NFO')) {
      $parameters = explode('/',getenv('PATH_ INFO'));
      for ($i = 1; $i < count($paramete rs); $i = $i + 2) {
      if (isset($paramet ers[$i + 1]))
      $$parameters[$i] = $parameters[$i + 1];
      }
      }

      Now, $nam is set (globally if you did this in the proper scope) w/ 'val' as
      the value.

      - Bill

      Comment

      Working...