Magento 2 – Set Cache-Control in HTTP Headers for UI Components

cachemagento2performanceuicomponent

The main delay in Magento page loading into client browser is the js/html files summary delay. So, my homepage is loading about 9 sec., DOMContentLoaded = 1.75 sec. (PHP generated HTML) and all other time is for CSS/IMG/JS/HTML loading.

I see that HTTP headers contain "Cache-Control:no-cache" in the responses for JS & HTML files. Can I set up "Cache-Control" headers for these files on Magento level or web server level (I use apache2)?

enter image description here

Best Answer

Do you have pub/static/.htaccess file on your magento instance? If no then you can find it here.

You also need mod_expires enabled on your apache. If it's not then enable it.

Hope this helps.