I would like to ask if there is a way to prevent Firefox from caching scripts (.js files).
I have a project (ASP.Net Web App) with caching issue on firefox. When I first
1) Install IIS module: http://www.iis.net/download/urlrewrite
2) Put this in web.config into section:
3) Write this helper function (into some global class)
public static string PutCSS(string filepath)
{
FileInfo f = new FileInfo(HttpContext.Current.Server.MapPath(filepath));
string timestamp = f.LastWriteTimeUtc.Year.ToString() + f.LastWriteTimeUtc.Month.ToString() + f.LastWriteTimeUtc.Day.ToString() + f.LastWriteTimeUtc.Hour.ToString() + f.LastWriteTimeUtc.Minute.ToString() + f.LastWriteTimeUtc.Second.ToString() + f.LastWriteTimeUtc.Millisecond.ToString();
return "\n";
}
public static string PutJS(string filepath)
{
FileInfo f = new FileInfo(HttpContext.Current.Server.MapPath(filepath));
string timestamp = f.LastWriteTimeUtc.Year.ToString() + f.LastWriteTimeUtc.Month.ToString() + f.LastWriteTimeUtc.Day.ToString() + f.LastWriteTimeUtc.Hour.ToString() + f.LastWriteTimeUtc.Minute.ToString() + f.LastWriteTimeUtc.Second.ToString() + f.LastWriteTimeUtc.Millisecond.ToString();
return "\n";
}
4) Instead of:
Use:
<%= global.PutCSS("Styles/style.css")%>
<%= global.PutCSS("Javascript/userscript.css")%>