IE does not reload css or js file...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew Wells

    IE does not reload css or js file...

    Hello,

    I'm working on an ASP.net 2.0 web project using VS 2005. I'm on my laptop
    running IIS on WinXP SP2 with all the latest updates. The Default web site
    is set to run on .net 2.0 My project uses a master page.

    I have two separate issues that I think are related.

    First, I can't figure out why changes to my CSS don't load when I start the
    project. The css is in the master page. The CSS loads, but only the last
    version I hit F5 for. I always have to hit F5 to see the changes. I set
    the IE option to Check for newer versions of stored pages every time I visit
    the webpage. Yes I closed all instances of IE and even rebooted for good
    measure. No luck.

    Second, I can't get javascript to work when it's being called using the src
    attribute. I use

    <script type="text/javascript" src="test.js" ></script>

    test.js is in the same folder as test.aspx, which calls it. I stripped
    everything out of the files - even the code-behind file. All that's in the
    ..js file is an alert function. The only thing on the web form is a button
    that calls the function using OnClientClick. It works if I put the function
    in the web form so I know javascript works. I had a brief moment of success
    when it worked - I thought - but it was having the same problem as the CSS -
    It would not show the latest changes without hitting F5. I would make the
    message "aaaaa" and start the project, hit F5 and see "aaaaa". I'd stop the
    project, change the message to "bbbbb", start the project and still see
    "aaaaa" until I hit F5 and see "bbbbb".

    This is why I think the CSS and javascript problems are related.

    Does anyone know why this is happening?

    Thanks.

    Matthew Wells
    Matthew.Wells@F irstByte.net


  • Fernando Rodriguez, MCP

    #2
    Re: IE does not reload css or js file...

    Try adding a Global.asax file and on it's Application_Beg inRequest method
    add the following:

    HttpContext.Cur rent.Response.E xpires = 0;
    HttpContext.Cur rent.Response.E xpiresAbsolute = DateTime.Now.Ad dDays(- 2);
    HttpContext.Cur rent.Response.C acheControl = "private";
    HttpContext.Cur rent.Response.A ddHeader("pragm a", "no-cache");

    That should prevent your browser from caching any files.

    I'm pretty sure it will also affect the .js and .css files when you load
    them from an ASPX page, but if it doesn't you can just rename your .js and
    ..css files to .aspx and it will be fine.

    Hope that helps,
    Fernando L Rodriguez, MCP

    "Matthew Wells" <Matthew.Wells@ FirstByte.netwr ote in message
    news:CIWdnYVmlf hqAYHVnZ2dnUVZ_ h2pnZ2d@comcast .com...
    Hello,
    >
    I'm working on an ASP.net 2.0 web project using VS 2005. I'm on my laptop
    running IIS on WinXP SP2 with all the latest updates. The Default web
    site is set to run on .net 2.0 My project uses a master page.
    >
    I have two separate issues that I think are related.
    >
    First, I can't figure out why changes to my CSS don't load when I start
    the project. The css is in the master page. The CSS loads, but only the
    last version I hit F5 for. I always have to hit F5 to see the changes. I
    set the IE option to Check for newer versions of stored pages every time I
    visit the webpage. Yes I closed all instances of IE and even rebooted for
    good measure. No luck.
    >
    Second, I can't get javascript to work when it's being called using the
    src attribute. I use
    >
    <script type="text/javascript" src="test.js" ></script>
    >
    test.js is in the same folder as test.aspx, which calls it. I stripped
    everything out of the files - even the code-behind file. All that's in
    the .js file is an alert function. The only thing on the web form is a
    button that calls the function using OnClientClick. It works if I put the
    function in the web form so I know javascript works. I had a brief moment
    of success when it worked - I thought - but it was having the same problem
    as the CSS - It would not show the latest changes without hitting F5. I
    would make the message "aaaaa" and start the project, hit F5 and see
    "aaaaa". I'd stop the project, change the message to "bbbbb", start the
    project and still see "aaaaa" until I hit F5 and see "bbbbb".
    >
    This is why I think the CSS and javascript problems are related.
    >
    Does anyone know why this is happening?
    >
    Thanks.
    >
    Matthew Wells
    Matthew.Wells@F irstByte.net
    >
    >

    Comment

    • David

      #3
      Re: IE does not reload css or js file...

      This is just down to caching. If your JS and CSS files are not dynamic, then
      when on your site, it shouldn't be an issue...

      However, when you run the project from VS, if the files are not there, then
      simply press and hold your CTRL key whilst you press the refresh button (or
      press CTRL-F5 whilst browser is focussed).

      This will get you the latest version.

      --
      Best regards,
      Dave Colliver.

      ~~
      http://www.FOCUSPortals.com - Local franchises available


      "Matthew Wells"
      Hello,
      >
      I'm working on an ASP.net 2.0 web project using VS 2005. I'm on my laptop
      running IIS on WinXP SP2 with all the latest updates. The Default web
      site is set to run on .net 2.0 My project uses a master page.
      >
      I have two separate issues that I think are related.
      >
      First, I can't figure out why changes to my CSS don't load when I start
      the project. The css is in the master page. The CSS loads, but only the
      last version I hit F5 for. I always have to hit F5 to see the changes. I
      set the IE option to Check for newer versions of stored pages every time I
      visit the webpage. Yes I closed all instances of IE and even rebooted for
      good measure. No luck.
      >
      Second, I can't get javascript to work when it's being called using the
      src attribute. I use
      >
      <script type="text/javascript" src="test.js" ></script>
      >
      test.js is in the same folder as test.aspx, which calls it. I stripped
      everything out of the files - even the code-behind file. All that's in
      the .js file is an alert function. The only thing on the web form is a
      button that calls the function using OnClientClick. It works if I put the
      function in the web form so I know javascript works. I had a brief moment
      of success when it worked - I thought - but it was having the same problem
      as the CSS - It would not show the latest changes without hitting F5. I
      would make the message "aaaaa" and start the project, hit F5 and see
      "aaaaa". I'd stop the project, change the message to "bbbbb", start the
      project and still see "aaaaa" until I hit F5 and see "bbbbb".
      >
      This is why I think the CSS and javascript problems are related.
      >
      Does anyone know why this is happening?
      >
      Thanks.
      >
      Matthew Wells
      Matthew.Wells@F irstByte.net
      >
      >

      Comment

      • Matthew Wells

        #4
        Re: IE does not reload css or js file...

        The files are there and as I said everything works after I hit F5 or Ctrl
        F5. I've also started the project using Ctrl F5. I'm going to try the
        suggestion in the first reply, but I shouldn't have to go through that.
        I'll let you know.

        Thanks.


        "David" <david.colliver .NEWS@revilloc. REMOVETHIS.comw rote in message
        news:%23uCDVScr IHA.3780@TK2MSF TNGP03.phx.gbl. ..
        This is just down to caching. If your JS and CSS files are not dynamic,
        then when on your site, it shouldn't be an issue...
        >
        However, when you run the project from VS, if the files are not there,
        then simply press and hold your CTRL key whilst you press the refresh
        button (or press CTRL-F5 whilst browser is focussed).
        >
        This will get you the latest version.
        >
        --
        Best regards,
        Dave Colliver.

        ~~
        http://www.FOCUSPortals.com - Local franchises available
        >
        >
        "Matthew Wells"
        >Hello,
        >>
        >I'm working on an ASP.net 2.0 web project using VS 2005. I'm on my
        >laptop running IIS on WinXP SP2 with all the latest updates. The Default
        >web site is set to run on .net 2.0 My project uses a master page.
        >>
        >I have two separate issues that I think are related.
        >>
        >First, I can't figure out why changes to my CSS don't load when I start
        >the project. The css is in the master page. The CSS loads, but only the
        >last version I hit F5 for. I always have to hit F5 to see the changes.
        >I set the IE option to Check for newer versions of stored pages every
        >time I visit the webpage. Yes I closed all instances of IE and even
        >rebooted for good measure. No luck.
        >>
        >Second, I can't get javascript to work when it's being called using the
        >src attribute. I use
        >>
        ><script type="text/javascript" src="test.js" ></script>
        >>
        >test.js is in the same folder as test.aspx, which calls it. I stripped
        >everything out of the files - even the code-behind file. All that's in
        >the .js file is an alert function. The only thing on the web form is a
        >button that calls the function using OnClientClick. It works if I put
        >the function in the web form so I know javascript works. I had a brief
        >moment of success when it worked - I thought - but it was having the same
        >problem as the CSS - It would not show the latest changes without hitting
        >F5. I would make the message "aaaaa" and start the project, hit F5 and
        >see "aaaaa". I'd stop the project, change the message to "bbbbb", start
        >the project and still see "aaaaa" until I hit F5 and see "bbbbb".
        >>
        >This is why I think the CSS and javascript problems are related.
        >>
        >Does anyone know why this is happening?
        >>
        >Thanks.
        >>
        >Matthew Wells
        >Matthew.Wells@F irstByte.net
        >>
        >>
        >
        >

        Comment

        • David

          #5
          Re: IE does not reload css or js file...

          No, not starting the project with ctrl-f5, but just press ctrl-f5 in your
          browser to force it to download the latest (uncached) files.


          --
          Best regards,
          Dave Colliver.

          ~~
          http://www.FOCUSPortals.com - Local franchises available


          "Matthew Wells"
          The files are there and as I said everything works after I hit F5 or Ctrl
          F5. I've also started the project using Ctrl F5. I'm going to try the
          suggestion in the first reply, but I shouldn't have to go through that.
          I'll let you know.
          >
          Thanks.
          >
          >
          "David" <david.colliver .NEWS@revilloc. REMOVETHIS.comw rote in message
          news:%23uCDVScr IHA.3780@TK2MSF TNGP03.phx.gbl. ..
          >This is just down to caching. If your JS and CSS files are not dynamic,
          >then when on your site, it shouldn't be an issue...
          >>
          >However, when you run the project from VS, if the files are not there,
          >then simply press and hold your CTRL key whilst you press the refresh
          >button (or press CTRL-F5 whilst browser is focussed).
          >>
          >This will get you the latest version.
          >>
          >--
          >Best regards,
          >Dave Colliver.
          >http://www.AshfieldFOCUS.com
          >~~
          >http://www.FOCUSPortals.com - Local franchises available
          >>
          >>
          >"Matthew Wells"
          >>Hello,
          >>>
          >>I'm working on an ASP.net 2.0 web project using VS 2005. I'm on my
          >>laptop running IIS on WinXP SP2 with all the latest updates. The
          >>Default web site is set to run on .net 2.0 My project uses a master
          >>page.
          >>>
          >>I have two separate issues that I think are related.
          >>>
          >>First, I can't figure out why changes to my CSS don't load when I start
          >>the project. The css is in the master page. The CSS loads, but only
          >>the last version I hit F5 for. I always have to hit F5 to see the
          >>changes. I set the IE option to Check for newer versions of stored pages
          >>every time I visit the webpage. Yes I closed all instances of IE and
          >>even rebooted for good measure. No luck.
          >>>
          >>Second, I can't get javascript to work when it's being called using the
          >>src attribute. I use
          >>>
          >><script type="text/javascript" src="test.js" ></script>
          >>>
          >>test.js is in the same folder as test.aspx, which calls it. I stripped
          >>everything out of the files - even the code-behind file. All that's in
          >>the .js file is an alert function. The only thing on the web form is a
          >>button that calls the function using OnClientClick. It works if I put
          >>the function in the web form so I know javascript works. I had a brief
          >>moment of success when it worked - I thought - but it was having the
          >>same problem as the CSS - It would not show the latest changes without
          >>hitting F5. I would make the message "aaaaa" and start the project, hit
          >>F5 and see "aaaaa". I'd stop the project, change the message to
          >>"bbbbb", start the project and still see "aaaaa" until I hit F5 and see
          >>"bbbbb".
          >>>
          >>This is why I think the CSS and javascript problems are related.
          >>>
          >>Does anyone know why this is happening?
          >>>
          >>Thanks.
          >>>
          >>Matthew Wells
          >>Matthew.Wells@F irstByte.net
          >>>
          >>>
          >>
          >>
          >
          >

          Comment

          • bruce barker

            #6
            Re: IE does not reload css or js file...

            a f5 in IE will not reload css or javascript files that are caches. you
            must delete the cache.

            switch to firefox and the developer extension, you can flip a setting to
            reload javascript and css while debugging. if you must use IE, then load
            its dev toolbar, at least it has a button to delete cache.

            -- bruce (sqlwork.com)


            David wrote:
            No, not starting the project with ctrl-f5, but just press ctrl-f5 in your
            browser to force it to download the latest (uncached) files.
            >
            >

            Comment

            • fd123456@hotmail.com

              #7
              Re: IE does not reload css or js file...

              I believe his problem is not on his browser's side but on his server's
              side. IIS will cache the css stylesheet and will not always detect
              when it's changed (i.e. if the file is programmaticall y modified
              instead of copied/deleted/created).

              To disable CSS caching (and most of the caching mechanisms, be
              warned...), on the server, create the following registry key :

              HKEY_LOCAL_MACH INE\System\Curr entControlSet\S ervices\HTTP\Pa rameters
              \UriEnableCache

              ...and set it to 0 (zero).

              This works on IIS 7, don't know about other versions but it's worth a
              try.

              Don't know if it will help with the js problem, though.

              Warning : always make a backup of the registry before editing, be
              extra careful if it's a production server, etc, you know the drill.

              HTH,

              Michel




              On 3 mai, 19:12, "Matthew Wells" <Matthew.We...@ FirstByte.netwr ote:
              Hello,
              >
              I'm working on an ASP.net 2.0 web project using VS 2005.  I'm on my laptop
              running IIS on WinXP SP2 with all the latest updates.  The Default web site
              is set to run on .net 2.0   My project uses a master page.
              >
              I have two separate issues that I think are related.
              >
              First, I can't figure out why changes to my CSS don't load when I start the
              project.  The css is in the master page.  The CSS loads, but only the last
              version I hit F5 for.  I always have to hit F5 to see the changes.  I set
              the IE option to Check for newer versions of stored pages every time I visit
              the webpage.  Yes I closed all instances of IE and even rebooted for good
              measure.  No luck.
              >
              Second, I can't get javascript to work when it's being called using the src
              attribute.  I use
              >
              <script type="text/javascript" src="test.js" ></script>
              >
              test.js is in the same folder as test.aspx, which calls it.  I stripped
              everything out of the files - even the code-behind file.  All that's in the
              .js file is an alert function.  The only thing on the web form is a button
              that calls the function using OnClientClick.  It works if I put the function
              in the web form so I know javascript works.  I had a brief moment of success
              when it worked - I thought - but it was having the same problem as the CSS-
              It would not show the latest changes without hitting F5.  I would make the
              message "aaaaa" and start the project, hit F5 and see "aaaaa".  I'd stopthe
              project, change the message to "bbbbb", start the project and still see
              "aaaaa" until I hit F5 and see "bbbbb".
              >
              This is why I think the CSS and javascript problems are related.
              >
              Does anyone know why this is happening?
              >
              Thanks.
              >
              Matthew Wells
              Matthew.We...@F irstByte.net

              Comment

              • Matthew Wells

                #8
                Re: IE does not reload css or js file...

                This one worked at first. I remmed out the lines and it failed. Then I
                unremmed them and it still didn't work. Still can't get it to refresh
                without manually hitting F5.


                "Fernando Rodriguez, MCP" <frodriguez.im@ hotmail.comwrot e in message
                news:481d2463$0 $3361$4c368faf@ roadrunner.com. ..
                Try adding a Global.asax file and on it's Application_Beg inRequest method
                add the following:
                >
                HttpContext.Cur rent.Response.E xpires = 0;
                HttpContext.Cur rent.Response.E xpiresAbsolute = DateTime.Now.Ad dDays(-
                2);
                HttpContext.Cur rent.Response.C acheControl = "private";
                HttpContext.Cur rent.Response.A ddHeader("pragm a", "no-cache");
                >
                That should prevent your browser from caching any files.
                >
                I'm pretty sure it will also affect the .js and .css files when you load
                them from an ASPX page, but if it doesn't you can just rename your .js and
                .css files to .aspx and it will be fine.
                >
                Hope that helps,
                Fernando L Rodriguez, MCP
                >
                "Matthew Wells" <Matthew.Wells@ FirstByte.netwr ote in message
                news:CIWdnYVmlf hqAYHVnZ2dnUVZ_ h2pnZ2d@comcast .com...
                >Hello,
                >>
                >I'm working on an ASP.net 2.0 web project using VS 2005. I'm on my
                >laptop running IIS on WinXP SP2 with all the latest updates. The Default
                >web site is set to run on .net 2.0 My project uses a master page.
                >>
                >I have two separate issues that I think are related.
                >>
                >First, I can't figure out why changes to my CSS don't load when I start
                >the project. The css is in the master page. The CSS loads, but only the
                >last version I hit F5 for. I always have to hit F5 to see the changes.
                >I set the IE option to Check for newer versions of stored pages every
                >time I visit the webpage. Yes I closed all instances of IE and even
                >rebooted for good measure. No luck.
                >>
                >Second, I can't get javascript to work when it's being called using the
                >src attribute. I use
                >>
                ><script type="text/javascript" src="test.js" ></script>
                >>
                >test.js is in the same folder as test.aspx, which calls it. I stripped
                >everything out of the files - even the code-behind file. All that's in
                >the .js file is an alert function. The only thing on the web form is a
                >button that calls the function using OnClientClick. It works if I put
                >the function in the web form so I know javascript works. I had a brief
                >moment of success when it worked - I thought - but it was having the same
                >problem as the CSS - It would not show the latest changes without hitting
                >F5. I would make the message "aaaaa" and start the project, hit F5 and
                >see "aaaaa". I'd stop the project, change the message to "bbbbb", start
                >the project and still see "aaaaa" until I hit F5 and see "bbbbb".
                >>
                >This is why I think the CSS and javascript problems are related.
                >>
                >Does anyone know why this is happening?
                >>
                >Thanks.
                >>
                >Matthew Wells
                >Matthew.Wells@F irstByte.net
                >>
                >>
                >
                >

                Comment

                • Matthew Wells

                  #9
                  Re: IE does not reload css or js file...

                  This one seemed to wokrk!!!! Thanks!!!! There is still a timing issue with
                  javascript, but I'll put that one in a separate post.

                  Matthew Wells
                  Matthew.Wells@F irstByte.net


                  <fd123456@hotma il.comwrote in message
                  news:801b3f79-9060-4f8c-a9ce-3385753d912f@2g 2000hsn.googleg roups.com...
                  I believe his problem is not on his browser's side but on his server's
                  side. IIS will cache the css stylesheet and will not always detect
                  when it's changed (i.e. if the file is programmaticall y modified
                  instead of copied/deleted/created).

                  To disable CSS caching (and most of the caching mechanisms, be
                  warned...), on the server, create the following registry key :

                  HKEY_LOCAL_MACH INE\System\Curr entControlSet\S ervices\HTTP\Pa rameters
                  \UriEnableCache

                  ....and set it to 0 (zero).

                  This works on IIS 7, don't know about other versions but it's worth a
                  try.

                  Don't know if it will help with the js problem, though.

                  Warning : always make a backup of the registry before editing, be
                  extra careful if it's a production server, etc, you know the drill.

                  HTH,

                  Michel




                  On 3 mai, 19:12, "Matthew Wells" <Matthew.We...@ FirstByte.netwr ote:
                  Hello,
                  >
                  I'm working on an ASP.net 2.0 web project using VS 2005. I'm on my laptop
                  running IIS on WinXP SP2 with all the latest updates. The Default web site
                  is set to run on .net 2.0 My project uses a master page.
                  >
                  I have two separate issues that I think are related.
                  >
                  First, I can't figure out why changes to my CSS don't load when I start
                  the
                  project. The css is in the master page. The CSS loads, but only the last
                  version I hit F5 for. I always have to hit F5 to see the changes. I set
                  the IE option to Check for newer versions of stored pages every time I
                  visit
                  the webpage. Yes I closed all instances of IE and even rebooted for good
                  measure. No luck.
                  >
                  Second, I can't get javascript to work when it's being called using the
                  src
                  attribute. I use
                  >
                  <script type="text/javascript" src="test.js" ></script>
                  >
                  test.js is in the same folder as test.aspx, which calls it. I stripped
                  everything out of the files - even the code-behind file. All that's in the
                  .js file is an alert function. The only thing on the web form is a button
                  that calls the function using OnClientClick. It works if I put the
                  function
                  in the web form so I know javascript works. I had a brief moment of
                  success
                  when it worked - I thought - but it was having the same problem as the
                  CSS -
                  It would not show the latest changes without hitting F5. I would make the
                  message "aaaaa" and start the project, hit F5 and see "aaaaa". I'd stop
                  the
                  project, change the message to "bbbbb", start the project and still see
                  "aaaaa" until I hit F5 and see "bbbbb".
                  >
                  This is why I think the CSS and javascript problems are related.
                  >
                  Does anyone know why this is happening?
                  >
                  Thanks.
                  >
                  Matthew Wells
                  Matthew.We...@F irstByte.net

                  Comment

                  Working...