Fully Cache WordPress (HTML pages included) with AWS CloudFront CDN

Written specifically for multi-sites (WordPress MU)

 

  1. CloudFront: Create a new distribution pointing at server
    • set the origin to the server CNAME
      • this can be found under Network Admin > Domain Mapping
    • set Forward Headers to “Whitelist”
      • Whitelist the “Host” header
    • set Forward Cookies to “Whitelist”
      • paste the following into the Whitelist Cookies text box:
        • PHPSESSID
          wordpress_logged_in_*
          wordpress_test_cookie
          wp-settings-*
    • Add Site URL to CNAMEs
  2. CloudFront: Create a new Behavior in CloudFront for wp-admin pages
    • set Path Pattern to “wp-admin/*”
    • “Allow” all available HTTP methods
    • Set Forward Headers to “All”
    • Set Forward Cookies to “All”
    • Set Forward Query Strings to “Yes”
  3. CloudFront: Create another Behavior in CloudFront for wp-login.php page
    • set Path Pattern to “wp-login.php”
    • “Allow” all available HTTP methods
    • Set Forward Headers to “All”
    • Set Forward Cookies to “All”
    • Set Forward Query Strings to “Yes”
  4. CloudFront: Create yet another Behavior in CloudFront for xmlrpc.php page
    • set Path Pattern to “xmlrpc.php”
    • “Allow” all available HTTP methods
    • Set Forward Headers to “All”
    • Set Forward Cookies to “All”
    • Set Forward Query Strings to “Yes”
  5. Route53 / DNS: Point Site URL CNAME record to CloudFront distribution URL

Reference: http://www.danneh.org/2015/04/setting-wordpress-amazon-cloudfront/