Edge cache and CDN
Change how long pages and static files stay cached, purge by URL, tag, or everything, read the cache headers, and use site preview.
The edge cache stores pages and static files at Cloudflare's edge, in front of the server cache. Open your site, then Caching, to change the settings, purge, and turn on site preview for the environment you are looking at.
Change the cache settings
- Open your site, then Caching.
- Change how long pages and static files stay cached. The defaults are one hour for pages and 30 days for static files.
- Add paths that never cache.
- List query parameters that should not split the cache. Marketing parameters such as
utm_sourceare ignored already. - Save.
Avaloi saves the settings and applies them at the edge through a job.
What is never cached
Avaloi never caches a page for:
- a logged in visitor,
- a visitor with items in a cart,
- a POST request, or
- a response that sets a cookie.
If a plugin sets a cookie on every page and you want those pages cached, turn on Strip Set-Cookie in Tools. Cached responses then go out without the cookie.
Read the cache headers
Every response carries two headers:
x-avaloi-cache: HIT, MISS, BYPASS, STALE, or EXPIRED.x-avaloi-cache-reason: why the page was or was not cached.
Check them in your browser's network tools when a page does not behave as you expect.
Purge the cache
Clear cache clears the edge and the server together. You can purge:
- by URL, for a few pages,
- by tag, for everything a post touched, or
- everything.
Publishing a post purges the affected pages on its own. You can also purge static assets at the edge on their own, without touching pages.
Image optimization
Image optimization is a setting for the CDN. Turn it on or off for the environment.
Site preview
Site preview shows the site on its temporary domain for one hour to seven days. Responses carry x-avaloi-preview: active, and search engines are told not to index. Preview turns itself off when the time you picked runs out.
Geolocation and Early Hints
Geolocation adds the visitor's country, region, and city as request headers, so your code can read them. Early Hints and Force HTTPS live in the same edge settings. Change them from the dashboard, and Avaloi applies them at the edge through a job.
Limits
- Pages: cached for one hour by default.
- Static files: cached for 30 days by default.
- Site preview: one hour to seven days.
Quick answers
A page shows old content.
Clear the cache for that URL, or publish the post again. Check x-avaloi-cache to confirm the next response is a MISS.
Why is my page always BYPASS?
Read x-avaloi-cache-reason. A cookie, a cart, a login, or a POST stops caching. Strip Set-Cookie in Tools helps with plugin cookies.
Does Clear cache touch the server cache too? Yes. It clears the edge and the server together.
How do I show a client the site before DNS moves? Turn on site preview and share the temporary domain.
API
GET /v1/environments/{id}/cachePUT /v1/environments/{id}/cachePOST /v1/environments/{id}/cache/purgePUT /v1/environments/{id}/cdnPOST /v1/environments/{id}/cdn/purgeGET /v1/environments/{id}/edge/settingsPUT /v1/environments/{id}/edge/settingsPUT /v1/environments/{id}/tools/site-previewPOST /v1/environments/{id}/tools/cache/clear
Related
Still stuck?
Email [email protected] with your site name and what you tried, or send us a message.