473,320 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

JS File Caching

Hello,

My website stores JavaScript in .js files. From what I understand,
most web browsers cache .js files. My question is, if I make changes
to the file, how can I be sure that users will use the most recent
version of the JS file?

Thanks,
Attila
Jul 20 '05 #1
2 1316
On 16 Jan 2004 07:33:19 -0800, Attila <Th******************@hotmail.com>
wrote:
My website stores JavaScript in .js files. From what I understand,
most web browsers cache .js files. My question is, if I make changes
to the file, how can I be sure that users will use the most recent
version of the JS file?


Cache management with .js files (any file, really) should work the same as
it does with .htm(l) files. If it doesn't you have a bad browser.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2
JRS: In article <95*************************@posting.google.com> , seen
in news:comp.lang.javascript, Attila <Th******************@hotmail.com>
posted at Fri, 16 Jan 2004 07:33:19 :-
My website stores JavaScript in .js files. From what I understand,
most web browsers cache .js files. My question is, if I make changes
to the file, how can I be sure that users will use the most recent
version of the JS file?


Untested :

every page has

<script type="text/javascript">

document.write(
'<script type="text/javascript" src="version.js?' +
new Date() + '"></scr'+'ipt>'
)

</script>

version.js is thus effectively uncached.

File version.js contains ONLY

var LatestVersion = 99 // update number as needed
Other pages contain, after as above,

<script type="text/javascript">

document.write(
'<script type="text/javascript" src="page45.js?' +
LatestVersion + '"></scr'+'ipt>'
)

</script>
ISTR that script can write script blocks, but the </script> must be
concealed.

Now, changing the contents of version.js effectively invalidates all
caches, although it does not flush the old stuff. ???

Naturally, you can have an array for LatestVersion, to control cacheing
of different groups of pages independently.

/Untested.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: kyle | last post by:
If the developers make changes to .htm files the saved changes are updated to the web instantly, but if they change a .asp file the change does not show on the site, why is this? please help ...
7
by: clusardi2k | last post by:
Hello, I have a shared drive on SGI, Linux, and Windows. A second call to fopen doesn't create the file if it has been deleted. I would like to use fopen for its pointer return value to...
6
by: martin | last post by:
Hi, I have noticed that every aspx page that I created (and ascx file) has an assosiated resource file aspx.resx. However what I would like to do is have a single global resource file for the...
5
by: Raj | last post by:
What is the purpose of file system caching while creating a tablespace? Memory on the test server gets used up pretty quickly after a user executes a complex query(database is already activated),...
0
by: DaveK777 | last post by:
I'm about to start development on a new project in PHP, which I've never used before. I got the latest version (5.1.4) installed and running on my dev/test server, and I tried enabling APC since...
17
by: shineofleo | last post by:
Here is the situation: I wrote a VB programm, which stores all the information in a single Access database file using jet engine. It worked well, however one of my customs reported that there was...
5
by: Russell Warren | last post by:
I've got a case where I'm seeing text files that are either all null characters, or are trailed with nulls due to interrupted file access resulting from an electrical power interruption on the...
5
by: brett | last post by:
I read in text files based on the page a user has reqeusted. The files are not larger than 10k. Sometimes I may read in two files for one page but the total read doesn't exceed 15k. However, I'm...
17
by: NeoAlchemy | last post by:
I am starting to find more web pages that are using a query parameters after the JavaScript file. Example can be found at www.opensourcefood.com. Within the source you'll see: <script...
12
by: TS | last post by:
i have a need to possibly enable mutli language support. What benefit do i get by using a resource file instead of a custom xml solution? thanks!
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.