August 25th, 2024

Speeding Up Your Website Using Cloudflare Cache

Pillser implemented Cloudflare caching to improve website performance and search rankings, reducing response times significantly. Challenges with stale content management and automated cache purging were also addressed.

Read original articleLink Icon
Speeding Up Your Website Using Cloudflare Cache

Pillser has implemented Cloudflare caching to enhance website performance, which is crucial for improving Google search rankings. The author enabled features such as Tiered Cache and Cache Reserve, which significantly reduced response times from 100ms to under 10ms. Cache Rules were established to cache pages accessed by non-authenticated users, focusing on specific URL patterns. The flexibility of Cloudflare's rules language allows for tailored caching strategies, including caching by device type. The author also utilized strong ETags to manage cache invalidation effectively. However, challenges arose with serving stale content while revalidating, as the expected behavior did not occur consistently. The author noted a lack of features for setting a maximum age for stale content, which would allow for longer cache retention while still ensuring regular revalidation. Additionally, the author automated cache purging through the Cloudflare API, facilitating updates to individual product caches. Latency tests demonstrated that Cloudflare caching significantly improved response times across various regions, particularly benefiting users located farther from the origin server.

- Cloudflare caching enhances website performance and search rankings.

- Features like Tiered Cache and Cache Reserve drastically reduce response times.

- Cache Rules allow for specific caching strategies based on user authentication and URL patterns.

- Challenges exist in serving stale content while revalidating and managing cache expiration.

- Automated cache purging via the Cloudflare API streamlines updates to product caches.

Link Icon 7 comments
By @pbowyer - 3 months
> Serve Stale Content While Revalidating (Not Working as Expected)

> This is the only thing that I was not able to figure out.

For good reason, because (at the last time I tried this earlier this year) Cloudflare documents stale-while-revalidate as if it's supported [1], but it isn't [2], [3].

Cloudflare instead has a different behaviour [4], [5] which helps in some circumstances but not all.

I use Fastly's free CDN plan to get round this.

1. https://developers.cloudflare.com/cache/concepts/revalidatio...

2. https://community.cloudflare.com/t/support-for-stale-while-r...

3. https://community.cloudflare.com/t/when-will-cloudflare-full...

4. https://kerkour.com/cloudflare-stale-while-revalidate

5. https://stackoverflow.com/questions/48124415/does-cloudflare...

By @turtlebits - 3 months
Before adding complexity, try to make your web sites smaller!

I'm not a big fan of adding more complexity (infra and money) to improve performance.

By @arghwhat - 3 months
To use the cache you shouldn’t need to do any of this - just have appropriate cache headers.
By @daviding - 3 months
Some rough cost numbers of using this would be nice.
By @j45 - 3 months
Cloudflares free cache is pretty good as well.

Also have heard things like jscompress to reduce the number of calls on loading a page can go a long way too to boost speed.

By @wetimeai - 3 months
is is a quick fix. and for smaller websites i recommend it. However it has its limits and it can frustrate when you are developing. But in general yeah good free service.
By @taw1285 - 3 months
does this approach make sense for an app-router based nextjs app hosted on vercel?