Javascript seems to be cached -- changes are ignored

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DavidDiamond
    New Member
    • Apr 2007
    • 3

    #1

    Javascript seems to be cached -- changes are ignored

    I am writing in ASP.NET 2.0 and whenever I make a change to a js file, I need to rename it or the prior code is processed.

    Is it possible the javascript file is being cached? What do I need to do to allow me to modify the js file and have that be processed correctly?

    Thanks.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    I'm not sure about ASP.NET. You may have to ask in the .NET forum, but you could try this:
    Code:
    "myScript.js?preventCache=<%Now%>"
    or similar depending on your server-side language, or even use Math.random().

    Comment

    • DavidDiamond
      New Member
      • Apr 2007
      • 3

      #3
      Thanks acoder for the feedback.

      I've tried to open the Javascript console to set the timeout, by using javascript: in the browser, but nothing happens in IE or Firefox. Do you have any suggestions for what I might need to do to get the console applet to open?

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by DavidDiamond
        Thanks acoder for the feedback.

        I've tried to open the Javascript console to set the timeout, by using javascript: in the browser, but nothing happens in IE or Firefox. Do you have any suggestions for what I might need to do to get the console applet to open?
        I don't understand what you're trying to do here.

        When you include the javascript, just add a timestamp to prevent caching issues.

        Comment

        • DavidDiamond
          New Member
          • Apr 2007
          • 3

          #5
          I couldn't get your code to work, but changing it slightly to be

          "myScript.js?pr eventCache<%=No w%>"

          does work and solves my problem.

          Thank you so much again for your help.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Yes, the = was in the wrong place.

            Glad you got it working.

            Comment

            Working...