caching

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

    caching

    I have an html page that has a javascript file included as well, with
    the src == my.js. The problem is my page gets cached, which I want
    and my js file gets cached, which I don't want. Is there a way to
    just refresh the javacript file?

    thks

    ABC
  • Andy Fish

    #2
    Re: caching

    If you just want to refresh the js during development and test, control-f5
    seems to work in IE

    If you want it never to be cached in the production environment, you'll need
    to get the web server to generate a no-cache HTTP directive. you'll need to
    refer to the documentation for your web server on that one.

    Andy


    "ABC" <bcampbell@imag ictv.com> wrote in message
    news:3f323095.1 76977229@allnew s.nbnet.nb.ca.. .[color=blue]
    > I have an html page that has a javascript file included as well, with
    > the src == my.js. The problem is my page gets cached, which I want
    > and my js file gets cached, which I don't want. Is there a way to
    > just refresh the javacript file?
    >
    > thks
    >
    > ABC[/color]


    Comment

    • Grant Wagner

      #3
      Re: caching

      Andy Fish wrote:
      [color=blue]
      > If you just want to refresh the js during development and test, control-f5
      > seems to work in IE
      >
      > If you want it never to be cached in the production environment, you'll need
      > to get the web server to generate a no-cache HTTP directive. you'll need to
      > refer to the documentation for your web server on that one.
      >
      > Andy
      >
      > "ABC" <bcampbell@imag ictv.com> wrote in message
      > news:3f323095.1 76977229@allnew s.nbnet.nb.ca.. .[color=green]
      > > I have an html page that has a javascript file included as well, with
      > > the src == my.js. The problem is my page gets cached, which I want
      > > and my js file gets cached, which I don't want. Is there a way to
      > > just refresh the javacript file?
      > >
      > > thks
      > >
      > > ABC[/color][/color]

      One of the ways to deal with this is something like:

      <script type="text/javascript" src="my.js?vers ion=20030807093 4"></script>

      When you change my.js, change the HTML containing the reference to it and upload
      them both. This can be bothersome if you use the script in many HTML files,
      there are two other options to this:

      1) server-side includes: put the <script ...> tag in another file and use SSI to
      include that file on each page you want the script to appear on. Then you change
      the "version" value above in a single place and it will take effect on all pages

      2) client-side "includes": put

      document.write( '<script type="text/javascript"
      src="my.js?vers ion=20030807093 4"><\/script>');

      in /another/ script file ("myWrapper. js" or something), then include that one on
      your pages. If you never want your file cached you could use:

      document.write( '<script type="text/javascript" src="my.js?time stamp=' +
      (new Date()).getTime () +
      '"><\/script>');

      --
      | Grant Wagner <gwagner@agrico reunited.com>

      * Client-side Javascript and Netscape 4 DOM Reference available at:
      *


      * Internet Explorer DOM Reference available at:
      *
      Gain technical skills through documentation and training, earn certifications and connect with the community


      * Netscape 6/7 DOM Reference available at:
      * http://www.mozilla.org/docs/dom/domref/
      * Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
      * http://www.mozilla.org/docs/web-deve...upgrade_2.html


      Comment

      Working...