Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pavol Vasko 15 posts 126 karma points
    Dec 28, 2017 @ 13:49
    Pavol Vasko
    0

    Leverage browser caching

    Hi everybody,

    I have a questions regarding the Leverage browser caching - where to place it in my web.config.

    I found some useful information on here - gitHub however after inserting the code into my web.config the pageSpeed did not improve.

    The code I have uploaded was

    <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />

    And I have uploaded to my web.config file see code below:

    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true">
            <remove name="WebDAVModule" />
    
            <remove name="UmbracoModule" />
            <add name="UmbracoModule" type="Umbraco.Web.UmbracoModule,umbraco" />
    
            <remove name="ScriptModule" />
            <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    
            <remove name="ClientDependencyModule" />
            <add name="ClientDependencyModule" type="ClientDependency.Core.Module.ClientDependencyModule, ClientDependency.Core" />
    
            <!-- Needed for login/membership to work on homepage (as per http://stackoverflow.com/questions/218057/httpcontext-current-session-is-null-when-routing-requests) -->
            <remove name="FormsAuthentication" />
            <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
            <add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web" />
        </modules>
    
        <handlers accessPolicy="Read, Write, Script, Execute">
            <remove name="WebServiceHandlerFactory-Integrated" />
            <remove name="ScriptHandlerFactory" />
            <remove name="ScriptHandlerFactoryAppServices" />
            <remove name="ScriptResource" />
            <remove name="ClientDependency" />
            <remove name="MiniProfiler" />
    
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add verb="*" name="ClientDependency" preCondition="integratedMode" path="DependencyHandler.axd" type="ClientDependency.Core.CompositeFiles.CompositeDependencyHandler, ClientDependency.Core" />
            <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
            <remove name="OPTIONSVerbHandler" />
            <remove name="TRACEVerbHandler" />
            <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
    
    
    
        <!-- Adobe AIR mime type -->
        <staticContent>
                        <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
            <remove fileExtension=".air" />
            <mimeMap fileExtension=".air" mimeType="application/vnd.adobe.air-application-installer-package+zip" />
            <remove fileExtension=".svg" />
            <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
            <remove fileExtension=".woff" />
            <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
            <remove fileExtension=".woff2" />
            <mimeMap fileExtension=".woff2" mimeType="application/x-font-woff2" />
            <remove fileExtension=".less" />
            <mimeMap fileExtension=".less" mimeType="text/css" />
            <remove fileExtension=".mp4" />
            <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
            <remove fileExtension=".json" />
            <mimeMap fileExtension=".json" mimeType="application/json" />
        </staticContent>
    

    Thanks for any help and merry x-mas guys.

    Regards

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Jan 02, 2018 @ 11:10
    Alex Skrypnyk
    0

    Hi Pavol

    Try to add cacheControlCustom="public" :

    <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
    

    Also, it looks like google can do not make test again if you try to test the same url in a short period of time

    Thanks,

    Alex

  • OleP 67 posts 276 karma points
    Jan 04, 2018 @ 21:13
    OleP
    0

    Please post the error from Google Insights. I recently had quite a battle with Insights, so I might be able to help. I too added the "clientCache" code to my web.config along the way, but that was specifically for caching .svg files.

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    Jan 05, 2018 @ 11:24
    Paul Seal
    0

    How did you get it to cache the SVGs? I need to do the same thing.

  • OleP 67 posts 276 karma points
    Jan 05, 2018 @ 12:11
    OleP
    0

    Add this to the <staticContent> section of the web.config did it for me (like OP did):

    <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
    
  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    Jan 05, 2018 @ 13:18
    Paul Seal
    0

    Thanks Ole I was missing the cacheControlCustom attribute, but it still hasn't helped me.

    https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fwww.codeshare.co.uk&tab=desktop

  • OleP 67 posts 276 karma points
    Jan 05, 2018 @ 14:15
    OleP
    0

    I see no issues related to .svg files?

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    Jan 05, 2018 @ 18:00
    Paul Seal
    0

    Good point. It has fixed that issue now. Thanks. Still got the issue with the other ones though.

  • OleP 67 posts 276 karma points
    Jan 05, 2018 @ 19:00
    OleP
    0

    I'm pretty sure it's related to the ImageProcessor, try look at this:

    With ImageProcessor, error is present: https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fwww.codeshare.co.uk%2Fmedia%2F1319%2Fhqdefault-3.jpg%3Fquality%3D30%26format%3Dpng8

    Without ImageProcessor, error is gone: https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fwww.codeshare.co.uk%2Fmedia%2F1319%2Fhqdefault-3.jpg

    Do you need to convert the images from jpg to png8? If not, try to remove that parameter from the image url.

    I haven't experienced this myself, but I did struggle with Google wanting me to compress the images more. If you didn't already, you should add this: https://www.nuget.org/packages/ImageProcessor.Web.PostProcessor/

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Jan 05, 2018 @ 14:17
    Dan Diplo
    0

    In

    <staticContent>
      <remove fileExtension=".air" />
      <mimeMap fileExtension=".air" mimeType="application/vnd.adobe.air-application-installer-package+zip" />
      <remove fileExtension=".svg" />
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
      <remove fileExtension=".woff" />
      <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
      <remove fileExtension=".woff2" />
      <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
      <remove fileExtension=".eot" />
      <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
      <remove fileExtension=".ttf" />
      <mimeMap fileExtension=".ttf" mimeType="application/font-sfnt" />
      <remove fileExtension=".otf" />
      <mimeMap fileExtension=".otf" mimeType=" application/font-sfnt" />
      <remove fileExtension=".less" />
      <mimeMap fileExtension=".less" mimeType="text/css" />
      <remove fileExtension=".webp" />
      <mimeMap fileExtension=".webp" mimeType="image/webp" />
      <remove fileExtension=".mp4" />
      <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
      <remove fileExtension=".webm" />
      <mimeMap fileExtension=".webm" mimeType="video/webm" />
      <remove fileExtension=".ogv" />
      <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
      <remove fileExtension=".json" />
      <mimeMap fileExtension=".json" mimeType="application/json" />
    
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="8.00:00:00" />
    
    </staticContent>
    
Please Sign in or register to post replies

Write your reply to:

Draft