How to reduce server load with aggressive Cloudflare cache settings

Contents

Reading Time: 2 minutes

If your website is contains mostly content that doesn’t change too often, you can reduce server load significantly using aggressive caching settings on Cloudflare. Site wide aggressive caching is not the optimal solution for dynamic sites, but in a such case you can limit rules only for example on directory that contains photos or other static media files.

Please note, setting up caches might mess up your site, especially if it’s mostly dynamic. After setting up caching rules, you need to carefully test how they work on your site. You should exclude admin area and shopping cart etc.

Set up caching rules at Cloudflare’s Page Rules tab

Login to the Cloudflare dashboard and set up caching rules opening the Page Rules tab. At the first you need to set up the URL for which the page rules are intended for. If you want deploy the rules site wide or on all sub-directories, use the asterisk mark accordingly.

Use browser Cache TTL to speed up loading time

Use browser Cache TTL to instruct how often browser should attempt to request new content from the website, i.e. from Cloudflare. That speeds up user’s visits on the page, except the first visit as user’s browser doesn’t request new content on every visit. It just loads it from local browser cache instead. If content is mostly static something like one day would be good.

Use Cache Level setting to cache everything

The Cache Level setting allows to specify what Cloudflare should cache. In this case we will use the Cache Everything option, so Cloudflare will cache everything like HTML, JSON data etc. instead of just the default data types.

Use aggressive Edge Cache TTL to reduce server load and bandwidth usage

The Edge Cache TTL setting instructs Cloudflare how often it should request new content from the website, i.e. from your server. Setting very aggressive TTL reduces server load and bandwidth usage significantly. We will set TTL to 7 days, so Cloudflare does the whole week the hard lifting, and requests new versions of the content from the server only after every 7 days. You can always manually purge the cache to refresh the cached content, when making updates.

 

Now the website loads much faster, and consumes less server resources.

5/5 - (3 votes)

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.