473,652 Members | 3,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I force the client to stop caching old stylesheets and javascript?

Can I force the client to stop caching old stylesheets and javascript?

In my dynamic web-site, I need to force the client to stop caching old
versions of my stylesheets and javascript. Can I do this by including
a querystring with the url with each external stylesheet and script
file declaration?

For example:

<link type="text/css" rel="stylesheet " href="../images/menu.css?
v=1" />
<script type="text/javascript" src="../javascript/menu.js?v=1"></
script>

This is far easier, for me, than coding the web-server to change the
file headers. I just want confirmation that this will work. It seems
obvious that it should but I'm curious as to why I've never come
across this technique before.

Oct 16 '07 #1
2 4304
On Tue, 16 Oct 2007 15:50:41 +0200, mark4asp <ma******@gmail .comwrote:
Can I force the client to stop caching old stylesheets and javascript?

In my dynamic web-site, I need to force the client to stop caching old
versions of my stylesheets and javascript. Can I do this by including
a querystring with the url with each external stylesheet and script
file declaration?

For example:

<link type="text/css" rel="stylesheet " href="../images/menu.css?
v=1" />
<script type="text/javascript" src="../javascript/menu.js?v=1"></
script>

This is far easier, for me, than coding the web-server to change the
file headers.
Shouldn't be...
I just want confirmation that this will work. It seems
obvious that it should but I'm curious as to why I've never come
across this technique before.
It works (well, as long as you keep changing the query string), and is
widely in use.
--
Rik Wasmus
Oct 16 '07 #2
mark4asp wrote:
Can I force the client to stop caching old stylesheets and javascript?

In my dynamic web-site, I need to force the client to stop caching old
versions of my stylesheets and javascript. Can I do this by including
a querystring with the url with each external stylesheet and script
file declaration?
Yes, but that's evil. Fortunately, you may be punished by a low google
rank! Crawlers assume that a URI uniquely identifies a resource.

Use the HTTP headers (e.g. set expiration to zero second). If the page is
generated by a script or contains SSI, your server should use the correct
headers by default.
If the page is static, then, why preventing caching? To improve the page
hits statistics? That would be stupid and evil.
What is it for?

I just want confirmation that this will work.
It will work as using pseudonyms to commit evil deeds reduces the chance
of being identified.
It seems obvious that it should but I'm curious as to why I've never come
across this technique before.
Because, modifying HTTP headers is much nicer, much more civilized, and
much more natural. It's the direct, obvious, fine, standardized way to
control caching. Your way, is worse than failure:
http://worsethanfailure.com/Default.aspx
--
If you've a question that doesn't belong to Usenet, contact me at
<ta************ *****@yahoDELET ETHATo.fr>
Oct 24 '07 #3

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

Similar topics

2
12633
by: Jonathan Driller | last post by:
I am attempting to block repeat downloads from a site. I need to have a landing page pass a referer to a secured page. I have tried a meta refresh redirect and several Javascript redirect strategies but none pass the referer. How can I force this since the referer property is read only? I have set up an .htaccess file so it will only let people into a secure directory if they come from an internal page on my site. This is done by...
1
1589
by: mwk24 | last post by:
Hi all, I have standard AJAX script that calls a php file to load the latest information and uses xmlHTTP.responseText to write it to innerHTML of a div by id. It works fine on IE/firefox, but I'm having trouble with Opera Mobile, due to javascript caching (at least that is my suspicion) I installed Opera for Windows and had the same problem (described below), until I set the Other Modification setting to 0 in opera.ini (i.e. to set Opera to...
1
2751
by: mwk24 | last post by:
Hi all, I have standard AJAX script that calls a php file to load the latest information and uses xmlHTTP.responseText to write it to innerHTML of a div by id. It works fine on IE/firefox, but I'm having trouble with Opera Mobile, due to javascript caching (at least that is my suspicion) I installed Opera for Windows and had the same problem (described below), until I set the Other Modification setting to 0 in opera.ini (i.e. to set Opera to...
1
1280
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I force a reload from the server/prevent caching? ----------------------------------------------------------------------- To reload a page, use location.reload(). However, this depends upon the cache headers that your server sends. To change this, you need to alter the server configuration. A quick fix on the client is to change the page URI so...
0
8367
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8279
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8703
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8589
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.