locked
How to fix Serve static content from a cookieless domain? RRS feed

  • Question

  • User2056202371 posted

    There are several ways to avoid this warning. The easiest way would be to use a CDN service and serve your static content through that. If that is not the option then I suggest you <g class="gr_ gr_7 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar replaceWithoutSep" id="7" data-gr-id="7">to</g> create a subdomain and use that for serving static content. I came across this warning on a few websites I host and this article here https://www.cloudways.com/blog/serve-static-content-from-a-cookieless-domain-guide/ helped me out in fixing ‘Serve Static Content From a Cookieless Domain’ warning.

    Friday, October 5, 2018 5:31 AM

All replies

  • User283571144 posted

    Hi alexpaul,

    There are several ways to avoid this warning. The easiest way would be to use a CDN service and serve your static content through that. If that is not the option then I suggest you to create a subdomain and use that for serving static content. I came across this warning on a few websites I host and this article here https://www.cloudways.com/blog/serve-static-content-from-a-cookieless-domain-guide/ helped me out in fixing ‘Serve Static Content From a Cookieless Domain’ warning.

    As far as I know, theServe static content from a cookieless domain means is that your content needs to come from a domain that has no cookies attached to it. 

    This is so that the client and the server don't have to waste resources on actually parsing and handling cookie data. You could use a sub-domain, assuming that you set your cookie path correctly.

    Like this :

    You should use below url as the static content instead of file path.

    You should use

    http://yourdomain/jquery-3.3.1.min.js 

    Instead of

    ../Scripts/jquery-3.3.1.min.js 

    Besides,  to create a cookieless site (or subdomain, which is a very common best-practice) in IIS: you need to tell the website that you are not to use cookies.

    Which means in IIS terms, not to use a session.

    You should define the session to off.

    <system.web>
            <sessionState cookieName="What_ever" mode="Off" />
    </system.web>

    Notice:  The attribute cookieless (true|false)does  NOT mean 'send cookies/do not sent cookies). That's for using sessions with/without cookies. You should also use the domain to host your static content.

    Best Regards,

    Brando

    Monday, October 8, 2018 3:03 AM