0

I have an ASP.NET webpage, which looks like this:

<%@ Page Language="VB" MasterPageFile="~/LGMaster.master" AutoEventWireup="false" Inherits="com.Genie.PresentationLayer.Web.frmPNList" title="Primary Nominals results list - RESTRICTED" Codebehind="frmPNList.aspx.vb" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

<script type="text/javascript"  src="Javascript/json2.js"></script>
<script type="text/javascript"  src="Javascript/massusnchange1014.js"></script>
<script type="text/javascript" src="Javascript/jquery-1.11.1.min.js"></script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:PlaceHolder runat="server" ID="NextBits" />
    <%--<input id="btnSave"  type="button" value="Group USN Change" onclick="GroupUSNChange();"/>--%>
    <%--<asp:Button ID="ButtonSetUSN" runat="server" Text="Set USN" OnClientClick="GetNewUSN()"></asp:Button>--%>     
    <asp:HiddenField ID="hfUSN" runat="server" ClientIDMode="Static" />
    <asp:HiddenField ID="hfGenieConnectionString" ClientIDMode="Static"  runat="server" />
    <asp:HiddenField ID="hfUserName" ClientIDMode="Static"  runat="server" />
    <button onclick="GetNewUSN()">Change USN of Group</button>
</asp:Content>

Each time I make a change to: massusnchange1014.js I have to increment it by 1 e.g. the next revision will be: massusnchange1015.js, otherwise I get errors implying the asp.net webpage is using the last revision.

Why is this?

w0051977
  • 15,099
  • 32
  • 152
  • 329

1 Answers1

1

Because your browser is helping you out by caching the content. Like a picture it's seen before, the browser caches the response it got back for a URL. If the URL changes, it goes and gets the content again. Otherwise, it has no idea you've changed it.

You have a couple of options.

Use ASP.NET's ClientScriptManager to bundle your JS - it handles changes like this.

if you need them to stay as individual files, you could append a timestamp from the file on the URL to produce new URLs.

n8wrl
  • 19,439
  • 4
  • 63
  • 103