Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On a Windows 2008 R2, using DNS and IIS I've established my development test server; i.e. I'll have a web application that I can browse on http://test.dev

I've moved all the static content files like images, js files and css files into another application which is visible on http://cdn.test.dev

test.dev, uses cdn.test.dev urls like http://cdn.test.dev/js/jquery.js to load js, css and images.

When I first load "~/" of test.dev, all files will load with a response code of 200; when I press F5 in Firefox, all files, except the "~/default.aspx", will load with 304 response code; but pressing Ctrl+F5 loads them again with a 200 code; if I browse another url like "~/pages/" in test.dev, all of those static files will reload with a 200 code... Is this normal or I'm doing something wrong?

Actually, I'm looking for a behavior like this:
I want the client to load http://cdn.test.dev/js/jquery.js, only once. I want the client's browser to use this jquery.js file, from cache, in all other pages of test.dev

Is this possible?

This is the web.config file I have in the root directory of cdn.test.dev:

<configuration>
    <system.webServer>
        <caching>
            <profiles>
                <add extension=".png" policy="CacheUntilChange" varyByHeaders="User-Agent" location="Client" />
                <add extension=".gif" policy="CacheUntilChange" varyByHeaders="User-Agent" location="Client" />
                <add extension=".jpg" policy="CacheUntilChange" varyByHeaders="User-Agent" location="Client" />
                <add extension=".js" policy="CacheUntilChange" varyByHeaders="User-Agent" location="Client" />
                <add extension=".css" policy="CacheUntilChange" varyByHeaders="User-Agent" location="Client" />
                <add extension=".axd" kernelCachePolicy="CacheUntilChange" varyByHeaders="User-Agent" location="Client" />
            </profiles>
        </caching>
        <httpProtocol allowKeepAlive="true">
            <customHeaders>
                <add name="Cache-Control" value="public, max-age=31536000" />
            </customHeaders>
        </httpProtocol>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true">
            <remove name="RadUploadModule" />
            <remove name="RadCompression" />
            <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" preCondition="integratedMode" />
            <add name="RadCompression" type="Telerik.Web.UI.RadCompression" preCondition="integratedMode" />
        </modules>
        <handlers>
            <remove name="ChartImage_axd" />
            <remove name="Telerik_Web_UI_SpellCheckHandler_axd" />
            <remove name="Telerik_Web_UI_DialogHandler_aspx" />
            <remove name="Telerik_RadUploadProgressHandler_ashx" />
            <remove name="Telerik_Web_UI_WebResource_axd" />
            <add name="ChartImage_axd" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" preCondition="integratedMode" />
            <add name="Telerik_Web_UI_SpellCheckHandler_axd" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" preCondition="integratedMode" />
            <add name="Telerik_Web_UI_DialogHandler_aspx" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode" />
            <add name="Telerik_RadUploadProgressHandler_ashx" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" preCondition="integratedMode" />
            <add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" preCondition="integratedMode" />
        </handlers>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="10485760" />
            </requestFiltering>
        </security>
        <staticContent>
           <clientCache cacheControlMode="UseExpires" httpExpires="Wed, 01 Jan 2020 00:00:00 GMT"/>
        </staticContent>
    </system.webServer>
    <appSettings />
    <system.web>
        <compilation debug="false" targetFramework="4.0" />
        <pages>
            <controls>
                <add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" />
            </controls>
        </pages>
        <httpHandlers>
            <add path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" validate="false" />
            <add path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" validate="false" />
            <add path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" validate="false" />
            <add path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" validate="false" />
            <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
        </httpHandlers>
        <httpModules>
            <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" />
            <add name="RadCompression" type="Telerik.Web.UI.RadCompression" />
        </httpModules>
        <httpRuntime maxRequestLength="10240" />
    </system.web>
</configuration>

and this is the resulting response header for http://cdn.test.dev/css/global.css:

Cache-Control: private,public, max-age=31536000
Content-Type: text/css
Content-Encoding: gzip
Expires: Wed, 01 Jan 2020 00:00:00 GMT
Last-Modified: Mon, 06 Sep 2010 08:53:06 GMT
Accept-Ranges: bytes
Etag: "0454eca04dcb1:0"
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Mon, 06 Sep 2010 14:57:08 GMT
Content-Length: 4495

share|improve this question

1 Answer 1

When I first load "~/" of test.dev, all files will load with a response code of 200; when I press F5 in Firefox, all files, except the "~/default.aspx", will load with 304 response code; but pressing Ctrl+F5 loads them again with a 200 code; if I browse another url like "~/pages/" in test.dev, all of those static files will reload with a 200 code... Is this normal or I'm doing something wrong?

In firefox (and most other browsers) shift+F5 reloads the site ignoring the cache.

share|improve this answer
1  
You mean Ctrl+F5 actually. Yes, it's like what you're talking about. but what if I want it to store a styles.css and use that cached stored file, shared between different pages inside a domain? –  Achilles Dec 9 '10 at 19:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.