1

We have a Magento 2.1.9 installation on a Debian Jessie server. It is configured to be connected with Cloudfront CDN for media and static files. The problem is that all the files that are served to CDN contain the header Cache-Control: private, so the Cloudfront behaves as a transparent proxy just forwarding the request to the Origin.

Preconditions

  1. Magento 2.1.9

  2. Connection with Cloudfront CDN

Steps to reproduce

  1. .htaccess in /pub/static/ contains:

    <FilesMatch .*\.(ico|jpg|jpeg|png|gif|svg|js|css|html|swf|eot|ttf|otf|woff|woff2)$>
     Header append Cache-Control public
    </FilesMatch>
    
  2. .htaccess in /pub/media/ contains:

    <FilesMatch .*\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$>
     Header append Cache-Control public
    </FilesMatch>
    

Expected result

  1. All files that are forwarding to CDN, except the ones that contain a non-cacheable block, to contain the header:

    -Cache-Control: public
    

Actual result

  1. All files that are forwarding to CDN contain 2 headers:

    -Cache-Control: public
    -Cache-Control: private
    
  2. In this configuration, Cloudfront behaves as a transparent proxy just forwarding the request to the Origin and we don't not benefit from Cloudfront caching.

asked Nov 22, 2017 at 4:06

1 Answer 1

0

Eventually the culprit was found. Magento works behind a nodeBalancer who puts the problematic header. I changed the nodeBalancer configuration and the problem resolved.

answered Nov 26, 2017 at 14:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.