> How can I prevent Caching of JavaScript and CSS files ONLY when I
> deploy a new application? I only want to force a refresh the first
[quoted text clipped - 6 lines]
>
> However that won't solve the problem of the css files.
If the file has changed, why would it used the cached copy?
mark4asp - 15 Oct 2007 15:34 GMT
> > How can I prevent Caching of JavaScript and CSS files ONLY when I
> > deploy a new application? I only want to force a refresh the first
[quoted text clipped - 8 lines]
>
> If the file has changed, why would it used the cached copy?
If a client or proxy has the "menu.js" cached then it will continue to
use
it until (a) the headers in the menu.js change (which can only be done
in
IIS as I understand it) or (b) the user refreshes the browser (e.g.
with an F5)
- this will make the page look like a dogs dinner (or worse) if I
change that
file when deploying a new application - that's a huge problem. I want
to
maximise the client caching of files whist ensuring that cached files
are
always updated on becoming obsolete.
the easiest is to change the name or folder, by appending the version.
cleaner than fake query strings.
-- bruce (sqlwork.com)
> How can I prevent Caching of JavaScript and CSS files ONLY when I
> deploy a new application? I only want to force a refresh the first
[quoted text clipped - 6 lines]
>
> However that won't solve the problem of the css files.
mark4asp - 15 Oct 2007 18:04 GMT
> the easiest is to change the name or folder, by appending the version.
> cleaner than fake query strings.
[quoted text clipped - 11 lines]
>
> > However that won't solve the problem of the css files.
Is there anything wrong with adding a querystring to the .css and .js
files?
It seems to me far easier than the other suggested methods: a) if I
append a querystring to the folder name, the client end up with
potentially lots of folders containing my obsolete code and it's also
more inconvenient for me. If I append a querystring to the filename
likewise then client still has the obsolete files cached.
Rad [Visual C# MVP] - 15 Oct 2007 18:31 GMT
>the easiest is to change the name or folder, by appending the version.
>cleaner than fake query strings.
>
>-- bruce (sqlwork.com)
I'm curious -- I don't see the drawback to the quasi query strings. If
anything they'd save the clutter of numerous folders for different
deployments
--
http://bytes.thinkersroom.com
mark4asp - 16 Oct 2007 14:10 GMT
> >the easiest is to change the name or folder, by appending the version.
> >cleaner than fake query strings.
[quoted text clipped - 6 lines]
>
> --http://bytes.thinkersroom.com
With the querystring version the only work needed is to add 1 to the
Build version in config.sys each time you deploy the new build.
web.config entry:
<appSettings>
<add key="BuildVersion" value="1"/>
</appSettings>
Global entry:
public static readonly string Build =
(string)ConfigurationManager.AppSettings["BuildVersion"];
Individual page entries:
<link type="text/css" rel="stylesheet" href="../images/menu.css?v=<
%=MyNS.Global.Build %>" />
<script type="text/javascript" src="../javascript/browser.js?v=<
%=MyNS.Global.Build %>"></script>
Seems like the way to go to me. Could anything be simpler than this?
mark4asp - 16 Oct 2007 14:13 GMT
> >the easiest is to change the name or folder, by appending the version.
> >cleaner than fake query strings.
[quoted text clipped - 6 lines]
>
> --http://bytes.thinkersroom.com
With the querystring version the only work needed is to add 1 to the
Build version in config.sys each time you deploy the new build.
web.config entry:
<appSettings>
<add key="BuildVersion" value="1"/>
</appSettings>
Global entry:
public static readonly string Build =
(string)ConfigurationManager.AppSettings["BuildVersion"];
Individual page entries:
<link type="text/css" rel="stylesheet" href="../images/menu.css?v=<
%=MyNS.Global.Build %>" />
<script type="text/javascript" src="../javascript/browser.js?v=<
%=MyNS.Global.Build %>"></script>
Seems like the way to go to me. Could anything be simpler than this?