0

Hallow Guys ! I did run speed test on my sites and most of the results shows that "Add Expire Headers" and "Defer parsing of Javascript" "Use Cookie-free Domains " If anyone know kindly help me ! Thanks in Advance

0

Using Cookie-free Domains

Basically that means loading static content that doesn't require any cookies to work from a different domain that doesn't have any cookies attached to it. This reduces network overhead as the browser doesn't need to attach cookie data to the request.

To achieve that you basically take the same steps you would when integrating a CDN, but instead of a CDN domain you can use any domain that points to the same folder as your main domain.

You can use the "Using a Content Delivery Network" from the Magento Developer Documentation as a reference: https://docs.magento.com/m2/ce/user_guide/system/media-storage-content-delivery-network.html

Add Expire Headers

If you are using Apache as a Webserver you can add the following to your .htacces file:

<IfModule mod_expires.c>
############################################
## Add default Expires header
ExpiresActive On
ExpiresDefault "access plus 1 year"
</IfModule>

Defer parsing of Javascript

As far as I am aware, there is no easy fix for that. The speed tests are complaining that your website loads Javascript files that block the rendering of the HTML until they are fully loaded and parsed. You could either move Javascript files to the bottom of your HTML right before the </body> tag or add async or defer attributes to the <script> tags. But Depending on your javascript this might break something.

You can read more about async and defer here: https://javascript.info/script-async-defer

| improve this answer | |
  • If i use CDN , cookie-free domain problem will be solved? – Syze Developer May 13 at 8:00
  • @SyzeDeveloper as long as your CDN is abailable on a domain where no cookies are set (which is usually the case), then yes. – disappointed.moose May 13 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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