In my last post, Grav in Azure part 4 - Adding DNS and Cloudflare to an App Service Web App, I demonstrated how to configure your Azure web app and its DNS to be managed by Cloudflare.
In this post, we'll go ahead and take a look at and optimise our Cloudflare configuration for performance and security.
Login to your clouflare account and look for the domain you just added/want to configure (in my case, cirriustech.co.uk) and click/tap on it:
By default the first thing you will see is an overview of traffic served via Cloudflate for this domain, but go ahead and click on the Crypto heading to view/change cryptography settings:
Now click on the Firewall heading.
Click on the Speed heading.
Click on the Caching heading
Mine were based on getting my rating on webpagetest.org to A for all the main factors it measures. I’m going to look into tweaking my deployment scripts in Azure to purge the Cloudflare cache (using their API) when I deploy into production - when i work that one out I’ll definitely blog about it!
Now, if you were paying attention earlier you’ll remember I mentioned Page Rules, so click on that heading now.
You get three page rules with your free account - if you need more you’ll need to upgrade your subscription to a paid one.
Click on Create Page Rule
This sets the cache level for the root domain to Cache Everything, sets the Edge Cache TTL (Time To Live) to 7 days e.g. when cache items are older than 7 days they will be served from the origin server and re-cached. It also enables Origin Cache Control. These work for me especially as I may not put up new posts more frequently than once a week to begin with, but feel free to experiment according to your needs.
I found that these settings significantly improved the speed and security of my website.
Stay tuned to the next post in the Grav in Azure series where I look into Performance and Security Optimisation in Grav itself. Between those and the Cloudflare optimisations discussed in this post I achieved A ratings on
webpagetest.org - though other metrics are worth using too for both performance and security - more on these in future posts.