Edge Caching for Web Services

Serve static content from a global edge cache for faster delivery.

This feature is currently in early access.

To request access, upvote the feature request at feedback.render.com. We'll gradually roll out access to requesting workspaces over the coming weeks.

Render is introducing edge caching support for static assets (documents, images, etc.) served by paid web services. With edge caching enabled, you can speed up response times and reduce load on your web service:

Diagram illustrating an edge cache hit

Edge caching is powered by the same global CDN as Render static sites.

Setup

  1. Request early access to this feature by upvoting the feature request at feedback.render.com.

    • We'll gradually roll out access to requesting workspaces over the coming weeks.
  2. After your workspace is added to early access, you can enable edge caching for any paid web service from its Settings page in the Render Dashboard.

How edge caching works

Whenever a client sends a GET or HEAD request to your cache-enabled web service, Render first checks its edge cache for the corresponding resource.

  • If the requested resource is in the cache (and the entry isn't stale), Render serves the cached version:

    Diagram illustrating an edge cache hit

    In this case, the request never reaches your web service. This speeds up the response and reduces load.

  • Otherwise, Render fetches the resource from your web service and caches it for future requests:

    Diagram illustrating an edge cache miss

Cache invalidation

To help ensure that clients receive up-to-date content, Render automatically invalidates edge cache entries in the following scenarios:

ScenarioDescription

New deploys

Each time you deploy a new version of your web service, Render purges all of its associated edge cache entries. This way, your deployed changes are reflected to clients as soon as possible.

TTL expiration

Each cache entry has a corresponding time-to-live (TTL). When an entry's TTL expires, the entry is considered stale. The next request for a stale entry is sent to your web service, which refreshes the entry.

Cache defaults

By default, Render caches static assets with the following file extensions (you can customize this by setting cache control headers in your service's responses):

7z avi avif bin bmp bz2 class css csv dmg doc docx eot ejs eps exe flac gif gz ico iso jar jpeg jpg js mid midi mkv mp3 mp4 ogg otf pdf pict pls png ppt pptx ps rar svg svgz swf tar tif tiff ttf webm webp woff woff2 xls xlsx zip zst

The default TTL for a cached asset is 120 minutes.

Render only caches assets returned for GET and HEAD requests. Render does not cache an asset if the response includes a Set-Cookie header.

Customizing cache behavior

You can customize Render's edge caching behavior for a particular resource by including a Cache-Control (or CDN-Cache-Control) header in your web service's response:

http
Cache-Control: public, max-age=7200

New to cache control headers?

Learn more about the response directives mentioned in the table below.

CustomizationDescription

Enable caching / Change TTL

Do both of the following in your response's cache control header:

  • Include the public directive.
  • Set the max-age or s-maxage directive to a value greater than 0.
http
Cache-Control: public, max-age=3600

Disable caching

Do either of the following in your response's cache control header:

  • Include the no-cache, no-store, or private directive.
  • Set the max-age or s-maxage directive to 0.
http
Cache-Control: no-cache

Set revalidation behavior

Include a combination of the must-revalidate, stale-while-revalidate, and stale-if-error directives.

http
Cache-Control: stale-while-revalidate=60, stale-if-error=3600, public, max-age=1200

Customization precedence

Render applies the following precedence rules to cache control headers:

  • The CDN-Cache-Control header takes precedence over the Cache-Control header.
  • The s-maxage directive takes precedence over the max-age directive.