locked
Combined script for default control bundle is not getting cached in browser RRS feed

  • Question

  • User765241231 posted

    I have added a CombineScriptsHandler in web.config and added a ToolkitScriptManager with the propertier ScriptMode="Release" CombineScripts="true".

    I could see that its combining the scripts to one file CombineScriptsHandler.axd in the response, but for somereason, its not getting cached in the browser (with a 304 Not Modified), instead it issues a seperate request on every refresh and ends up with 200 OK response).

    As per Stephen Walther's detailed documentation here , the combinedscript file is supposed to be cached - but unfortunately its not working for me.

    Is there any additional steps I am missing here to have this combined script file cached? Please advice.

    Monday, February 3, 2014 5:40 PM

All replies

  • User1734617369 posted

    Hi,

    If I do the same I can see when using the dev tools in Chrome that the status says 200 OK but the size of the content is retrieved from the cache, and if I look at the same page in IE I can see that I get an 304 and the scripts are retrieved from the cache. In your case what browser do you use?

    Best regards
    Johan

    Tuesday, February 4, 2014 6:23 AM
  • User765241231 posted

    Thanks Johan for the response.

    So I tried with IE7, IE8, IE9, Firefox v24 and Chrome. All of them showed 200 as the status for CombineScriptsHandler.axd. Should I set something explicitly to force this caching for the combined script?

    Tuesday, February 4, 2014 12:58 PM
  • User1734617369 posted

    Hi,

    Not that I know of, I made this simple example and that works fine when I try, the page:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
    
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" ScriptMode="Release" CombineScripts="True"></asp:ToolkitScriptManager>
        <div>
            <asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server" />    
        </div>
        </form>
    </body>
    </html>
    

    and the web.config

    <?xml version="1.0"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.5.1">
          <assemblies>
            <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
          </assemblies>
        </compilation>
        <httpRuntime targetFramework="4.5.1"/>
        <httpHandlers>
          <add verb="*" path="AjaxFileUploadHandler.axd"
               type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
          <add verb="*" path="CombineScriptsHandler.axd"
               type="AjaxControlToolkit.CombineScriptsHandler, AjaxControlToolkit" />
        </httpHandlers>
      </system.web>  
      
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <handlers>
          <add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd"
               type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
          <add name="CombineScriptsHandler" verb="*" path="CombineScriptsHandler.axd"
               type="AjaxControlToolkit.CombineScriptsHandler, AjaxControlToolkit" />
        </handlers>
        </system.webServer>
    </configuration>

    /Johan

    Wednesday, February 5, 2014 2:12 AM
  • User765241231 posted

    Hi Johan,

    I'm sorry for the delayed response: I was on vacation and couldnt get back on this afterwards.

    I tried your sample web page in firefox, chrome, IE7, IE8, IE9 and IE10  all of them shows "200" for CombineScriptsHandler.axd, which means its a request to fetch from the server and not from the browser cache.

    So we are back to square one now :(

    Thursday, February 13, 2014 4:59 PM
  • User1734617369 posted

    Hi,

    I did a new test and found out that the caching is not really stable, if I test in Chrome and reloads the page using F5, the caching is not used but i f I just reload the page by using a button on the page or by requesting the same url again it works, sometimes. I have seen others having the same issue and could see issues being registered on the toolkit codeplex site so I guess hat this feature is not stable as of now unfortunatelly.

    /Johan

    Friday, February 14, 2014 4:06 AM
  • User1821416443 posted

    I'm having same problem.  _TSM_CombinedScripts (240KB+ ) is reloaded on every page, is reloaded on refresh of any given page.  For Firefox, Chrome and IE:

    Problem 1 - why browsers not caching:

    1) I see in the response that Cache-Control is "public" (which is correct), however no "max-age" specified.  

    2) I see that "Last-Modified" is instead specified which is an acceptable alternative to max-age. But its value is set to one year + 1 day, which I suspect invalidates it ("Do not set it to more than one year in the future, as that violates the RFC guidelines." - https://developers.google.com/speed/docs/best-practices/caching):

    "Max-age" would take precedence over "Last-Modified" according to HTTP 1.1, and is a shame that TSM didn't implement,.

    Problem 2 - why a 200 response:

    Given that browser is re-making the same request, with same querystring parameter, over and over, TSM should have the smarts to reply with a 304 ("you've got the latest") and not re-issue then entire datastream over and over.

    I'm not git-enabled and the idea of undertaking custom changes to atk is daunting. However this issue is killing my client's website and we're too committed to atk to be able to pull it out.
    wish me luck.  
    rick.

    Friday, March 7, 2014 2:07 PM