Page Rules are conditions that your site will use. Page Rules let you control which Cloudflare settings trigger on a given URL. Only one Page Rule will trigger per URL, so it is helpful if you sort Page Rules in priority order, and make your URL patterns as specific as possible.
Remember that a Free Account can only get 3 page rules. |
Here is an explanation of page rules on the cloudflare site.
Here are the 3 best page rules to use with a free account.
CloudFlare allows a shared SSL cert and can force your page to operate via https.
Make sure this is the first rule if you add other rules.
http://*yourdomain.com/* |
Since the files themselves in the cache directory will most likely not change that often, we can cache them for speedier page loads
Enter your files directory like:
*yourdomain.com/sites/default/files* |
You can test to see if this is working by running this command in your terminal
curl -svo /dev/null https://yoursite.com/sites/default/files/filename.jpg |
If you are using core aggregation on D8 or Advanced Agg in D7, you don't need to do the next rule: Cache Theme Directory as all css and js are stored in sites/default/files. |
The theme directory on live doesn't get changed too often. Only CSS changes usually happen, in the case you can purge the cache via the cloudflare dashboard.
D7
*yourdomain.com/sites/all/themes* |
D8
*yourdomain.com/themes* |
You can test to see if this is working by running this command in your terminal
curl -svo /dev/null https://yoursite.com/sites/themes/themename/stuff.css |
If you have paid plan you would like to follow this document to setup advanced caching page rules
Make sure you are forcing https as described above. If your site is on Pantheon - make sure you setup all of the redirects to additional domains through CloudFlare and redirects are removed from settings.php otherwise you may run into infinite cache loop.
If your site is on Apache hosting (e. g. Acquia) then make sure you don't have httaccess redirects from additional domains and into https. And all of them are powered through CloudFlare UI.
Additionally it is also a good idea to exclude admin pages from caching.
Setup no caching on these ones.
Read more in this documentation
The result you are aiming for is cf-cache-status: HIT in the headers of your network tab in browser inspector after you load the page a couple times.
If the result says DYNAMIC - your page cache isn't working.
If the result says BYPASS - cookie is in place - check that your cookie exception is correct and you are not logged in.
It is essential to troubleshoot your cache. Go through multiple browsers like Safari and IE 11 and check that images are still loading, JS and CSS are still working as expected.
Tip: if your JS is not working turn off / on (switch to the opposite state) aggregation in Drupal performance menu. Save and clear the cache.
Go to CloudFlare and purge.
Turn on aggregation back and clear the cache again - it may take it some time to propagate.
Check these elements on every deployment.
Check search and time sensitive views - make sure they still update as expected.
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
|