This is a migrated thread and some comments may be shown as answers.
JS Shared Group Not Caching Properly
9 Answers 87 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Neal Kranes
Top achievements
Rank 1
Neal Kranes asked on 10 Mar 2010, 02:47 AM
I know this question has probably been answered but i could not seem to find it.  I am running VS2008 and IIS7 and using the Script Registrar to reference a shared group I have defined in the web.config:
    <telerik> 
        <webAssets> 
            <scripts> 
                <add name="JSGroup" combined="true" compress="true" enabled="true" version="1.0.0.0" cacheDurationInDays="10"
                    <items> 
                        <add source="~/subPathName/Scripts/file1.js"/> 
                        <add source="~/subPathName/Scripts/file2.js"/> 
                    </items> 
                </add> 
            </scripts> 
        </webAssets> 
    </telerik> 

And called from the site.master:
    <%  Html.Telerik().ScriptRegistrar() 
            .AssetHandlerPath("~/subPathName/asset.axd") 
            .Scripts(group => group.AddSharedGroup("JSGroup")) 
            .jQuery(false); %>      
    <asp:ContentPlaceHolder ID="JSContent" runat="server" /> 
    <%  Html.Telerik().ScriptRegistrar().Render();%> 
When a page is rendered, the browser will serve a cached version of asset.axd?id=JSGroup when reached through clicking a link, but does not return a cached version when pressing F5.  However, other JS and CSS files are returned from cache via a 304 when pressing F5.  If I press Ctrl-f5, nothing is served from cache as one would expect, but just pressing F5 should return cached versions of the asset.axd files as well.  Here are the headers returned for the asset.axd call:
HTTP/1.1 200 OK 
Cache-Control   public, must-revalidate, max-age=31536000 
Content-Type    application/x-javascript 
Content-Encoding    gzip 
Expires Thu, 10 Mar 2011 01:45:11 GMT 
Last-Modified   Wed, 10 Mar 2010 01:45:11 GMT 
Server  Microsoft-IIS/7.0 
X-AspNet-Version    2.0.50727 
X-Powered-By    ASP.NET 
Date    Wed, 10 Mar 2010 01:45:11 GMT 
Content-Length  132452 
I have debug set to false in the web.config.  Is this an IIS7 issue?  Has anyone experienced this issue before?  I was thinking it had to do with the file extension but couldn't find a way to fix this.  I've tried this from Firefox and IE but no dice.

Thanks!

9 Answers, 1 is accepted

Sort by
0
Kazi Manzur Rashid
Telerik team
answered on 10 Mar 2010, 02:57 PM
Hi Neal Kranes,

We are currently not generating the ETag for the web assets and this is the reason no 304 is issued in the server.

All the best,
Kazi Manzur Rashid
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Neal Kranes
Top achievements
Rank 1
answered on 10 Mar 2010, 06:24 PM
It seems even when I generate an Etag the server still does not return a 304.  Any other suggestions?
0
Kazi Manzur Rashid
Telerik team
answered on 11 Mar 2010, 08:31 AM
Hi Neal Kranes,

You also have to handle the "If Modified Since" and set the status code to 304 when the content is not modified, I don't think IIS will be helpful in this case.

Greetings,
Kazi Manzur Rashid
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Neal Kranes
Top achievements
Rank 1
answered on 11 Mar 2010, 03:24 PM
Great.  Thanks for the info.  Is there anything in the pipeline to support the asset handler sending the 304 status code when no files have changed?
0
Kazi Manzur Rashid
Telerik team
answered on 12 Mar 2010, 07:19 PM
Hi Neal Kranes,

Let me disscuss with the team, we will put in our road map, if you decide to implement it,


Regards,
Kazi Manzur Rashid
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Neal Kranes
Top achievements
Rank 1
answered on 12 Mar 2010, 07:32 PM
I've implemented a basic version myself for now.  Thanks much for your attention to this matter.
0
Karl
Top achievements
Rank 1
answered on 23 Mar 2010, 08:03 PM
Hi Neal,

I'm having the same issue as yourself. How do you go about implementing this?
0
Neal Kranes
Top achievements
Rank 1
answered on 24 Mar 2010, 01:08 AM
I did 2 things.
1) I added the shared group version # to the asset.axd querystring to bust the browser cache when a version # changes. 
2) For each asset group, I check the If-Modified-Since request header against the physical files in the group.  If the physical files dates are older than the header, I return a 304 status code and end the request.  Otherwise, I send the new asset group, a 200 status code and the new If-Modified-Since header.  There's a bit more to it, but that's the basics.  It works well for me, so I can keep sending 304's until a group version # changes or we change an underlying js or css file when we detect the change and resend the new asset group.
0
Binu Thayamkery
Top achievements
Rank 1
answered on 04 Jan 2011, 10:33 PM
We are using Shared Asset Groups for our scripts and it does not seems to cache in Browser as the OT suggests. Is there any hot fix in pipeline to handle this?
Tags
General Discussions
Asked by
Neal Kranes
Top achievements
Rank 1
Answers by
Kazi Manzur Rashid
Telerik team
Neal Kranes
Top achievements
Rank 1
Karl
Top achievements
Rank 1
Binu Thayamkery
Top achievements
Rank 1
Share this question
or