Caching if js Files

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

    #1

    Caching if js Files

    We have a problem with caching of js Files in our application.

    The situation is that in some location our application is not running
    well - the problem we identified was that not the actual js is used in
    these problem locations.

    We are using jsp and external javascript files. We have configured our
    webserver to insert into the http header cach-control and pragma -
    both parameters with no header.
    My problem is now that in we identified that the changes we made in
    the javascript are not directly displayed and used in the application.
    Also when the user is deleting the cache in the browser the wrong
    javascript is use to display the page.
    We also tried to download the js file directly from our webserver and
    then the correct js file was donwloaded.

    So my assumption is that either the proxies of our customer are not
    able to understand the http header we insert into our information we
    sent to them or our webserver is not well configured and we are not
    forcing the application to update existing js files in the customer's
    proxies.

    Does anybody has any idea what we should test? Or which parameters can
    help us to solve the problem with the not loaded js files?

    Thanks for help

    Dole
  • Grant Wagner

    #2
    Re: Caching if js Files

    Dole wrote:
    [color=blue]
    > We have a problem with caching of js Files in our application.
    >
    > The situation is that in some location our application is not running
    > well - the problem we identified was that not the actual js is used in
    > these problem locations.
    >
    > We are using jsp and external javascript files. We have configured our
    > webserver to insert into the http header cach-control and pragma -
    > both parameters with no header.
    > My problem is now that in we identified that the changes we made in
    > the javascript are not directly displayed and used in the application.
    > Also when the user is deleting the cache in the browser the wrong
    > javascript is use to display the page.
    > We also tried to download the js file directly from our webserver and
    > then the correct js file was donwloaded.
    >
    > So my assumption is that either the proxies of our customer are not
    > able to understand the http header we insert into our information we
    > sent to them or our webserver is not well configured and we are not
    > forcing the application to update existing js files in the customer's
    > proxies.
    >
    > Does anybody has any idea what we should test? Or which parameters can
    > help us to solve the problem with the not loaded js files?
    >
    > Thanks for help
    >
    > Dole[/color]

    To ensure the browser requests a new copy of your external client-side
    JavaScript files when they change, use a versioning system on the URL.
    Something like:

    <script type="text/javascript"
    src="ourClientS ideJS.js?v=2003 07111200"></script>

    When you change the file at 9am on August 17, 2003, you'd change this to:

    <script type="text/javascript"
    src="ourClientS ideJS.js?v=2003 08170900"></script>

    When the browser sees this new URL, it will determine is has not cached a
    copy of it and download a fresh copy from the server.

    If you need to use the same client-side file in multiple places, rather
    then change the value of "v" everywhere, put the <script ...></script> tag
    in a server-side include and #include it on every page you use it on, then
    you only need change the value of "v" in one place when the contents of
    ourClientSideJS .js changes.

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

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


    * Internet Explorer DOM Reference available at:
    *
    http://msdn.microsoft.com/workshop/a...ence_entry.asp

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


    Comment

    Working...