Mike Lewis
Programmer
Apoligies if this is not the correct forum for this question.
I am looking for a way to force a Javascript file in visitors' browser caches to be refreshed.
I have a site that contains many HTML pages, which is updated frequently. It has a small number of regular visitors. I understand the issues surrounding cached HTML pages, and this is not a problem. The visitors always see the latest version of each page, as you would expect.
But that is not the case with Javascript files. I'm finding that visitors are still being served old versions of JS files from their browser's cache, even when there is a new version on the server. I know that I can add an arbitrary parameter to the JS filename when calling it from HTML, like this:
[tt]
<script type="text/javascript" src="library.js[highlight #FCE94F]?n=1[/highlight]"></script>[/tt]
The [tt]?n=1[/tt] tells the browser that the file this is different from the cached version, and so the file is refreshed.
That work's OK. My problem is that I have the above line of code on every one of the site's pages, so I will have to apply the above change to each one in turn. I can do that, but I am wondering if there is some alternative way of achieving my goal that doesn't involve editing a large number of files.
Thanks in advance for any suggestions.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips and downloads
I am looking for a way to force a Javascript file in visitors' browser caches to be refreshed.
I have a site that contains many HTML pages, which is updated frequently. It has a small number of regular visitors. I understand the issues surrounding cached HTML pages, and this is not a problem. The visitors always see the latest version of each page, as you would expect.
But that is not the case with Javascript files. I'm finding that visitors are still being served old versions of JS files from their browser's cache, even when there is a new version on the server. I know that I can add an arbitrary parameter to the JS filename when calling it from HTML, like this:
[tt]
<script type="text/javascript" src="library.js[highlight #FCE94F]?n=1[/highlight]"></script>[/tt]
The [tt]?n=1[/tt] tells the browser that the file this is different from the cached version, and so the file is refreshed.
That work's OK. My problem is that I have the above line of code on every one of the site's pages, so I will have to apply the above change to each one in turn. I can do that, but I am wondering if there is some alternative way of achieving my goal that doesn't involve editing a large number of files.
Thanks in advance for any suggestions.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips and downloads