-
Notifications
You must be signed in to change notification settings - Fork 0
CloudFront
CloudFront, an Amazon Web Services tool provides us with a layer of caching that protects the website from high load. We can take particular advantage of this as our website doesn't change very often.
There is a single CloudFront Distribution to provide the cache. We mostly just needs default settings, but there are a couple of things that need to be set up correctly for WordPress to function as you would expect.
There is a single Origin defined, pointing at web.wehorr.org
. This represents the address that CloudFront will look at in order to fetch the website content. Note that this cannot be www.wehorr.org
as it would form a circular reference, looking up from itself.
We need four Behaviors defined, with preference in order:
-
wp-admin/*
defined with Query String Forwarding all and and Caching based on all. It should allow all HTTP methods and forward all Cookies. -
wp.login.php
as for the previous entry. -
/wp-json/*
defined as above, but with Whitelisted Headers for Host, Options and Referer. -
Default (*)
with onlyGET
,HEAD
andOPTIONS
allowed, Query String Forwarding all and some whitelisted cookies:
PHPSESSID
wordpress_logged_in_*
wordpress_test_cookie
wp-settings-*
This section is used when you change something on a page. When you do, create an invalidation that refers to the URL(s) of the pages you have changed in order to flush the cache. Note that there is a (fairly large) limit on the number of free invalidations per month, so if you're planning a lot of updates, batch them up and then use a wildcard invalidation.