Home ci 31. edge-network: caching

31. edge-network: caching

Last updated on Aug 05, 2025

Caching on Epycbyte's Edge Network: A Comprehensive Guide

Epycbyte's Edge Network provides a robust caching mechanism to optimize content delivery and improve performance. This guide explores the various aspects of caching, including how to cache responses, static file optimization, browser cache control, CDN-Cache-Control headers, cacheable response criteria, cache invalidation, and more.

Overview of Caching

Caching is a technique where data is stored in a temporary storage location to reduce access times and improve delivery speeds. Epycbyte's Edge Network leverages this technology to cache responses from server-side functions, static files, and other resources based on specific rules and configurations.


How to Cache Responses

Using Epycbyte Functions

Epycbyte Functions allow you to define caching behavior for your server-side responses. By setting appropriate headers in your function's response, you can control how the content is cached:

  • Cache-Control Headers: Use Cache-Control to specify caching rules such as max-age, s-maxage, and stale-while-revalidate.
  • Region-Specific Caching: Cache responses will be stored in the region where the request was made, ensuring that users receive content from the nearest edge location.

epycbyte.json Configuration

Epycbyte provides a configuration file (epycbyte.json) to define caching rules for static assets and other resources. This file allows you to specify:

  • Cache Duration: Set s-maxage or max-age to determine how long the content will be cached.
  • Region Targeting: Use region to restrict caching to specific regions.
  • Invalidate Cache: Define conditions under which the cache should be invalidated, such as on deployment updates or when certain headers are present.

next.config.js for Next.js Applications

If you're using Next.js, you can configure caching behavior in your next.config.js file. This allows you to:

  • Set default caching headers for static files.
  • Customize cache invalidation policies based on your deployment URL.
  • Optimize image delivery with lazy loading and responsive images.

Static File Caching

Static files, such as HTML, CSS, JavaScript, and images, can be cached by Epycbyte's Edge Network. This caching is automatically handled based on the file's content and size:

  • File Size Limits: Static files must not exceed 10MB for non-streaming functions or 20MB for streaming functions.
  • Cacheable Status: Files that meet the criteria will be cached in the user's browser and edge locations.

Browser Cache Control

The browser cache plays a crucial role in delivering cached content. Epycbyte ensures that:

  • Caching behavior adheres to Cache-Control headers set by your server or configuration files.
  • Cached content is served directly from the user's browser or the nearest edge location.

CDN-Cache-Control Headers

Epycbyte's Edge Network supports several headers that influence caching behavior, including:

  • Cache-Control: Controls how the browser and edge locations store and retrieve cached content.
  • Etag: A unique identifier for cache validation.
  • Last-Modified: Indicates when a resource was last updated, which can be used to determine if the cached version is still valid.

Cacheable Response Criteria

For a response to be cached, it must meet specific criteria:

  1. Cache-Control Header: Must include public or no-cache, depending on whether you want the content to be cacheable.
  2. Content-Type: Ensure that dynamic content (e.g., HTML, JSON) is marked as no-cache.
  3. Size and freshness: Keep cache durations reasonable to avoid serving stale content.

Cache Invalidation

Epycbyte's Edge Network automatically invalidates cached content under the following conditions:

  • On deployment updates: New code or configuration changes will invalidate existing caches.
  • When specific headers are present in the response (e.g., no-cache).
  • Manually via the Epycbyte dashboard.

Cache Limits and Performance

Epycbyte imposes limits on cache behavior to ensure optimal performance and reliability:

  • Max Age: The maximum duration a cached response can be stored.
  • Region-Specific Caching: Cache durations may vary by region due to latency and traffic patterns.
  • Streaming vs. Non-Streaming Functions: Maximum file sizes differ based on the type of function.

Additional Topics

  • Redirects and Proxy Settings: Configure redirects and proxy rules to ensure caching works correctly for your application.
  • Edge Rules: Define advanced caching policies for dynamic content and API responses.
  • Analytics and Logging: Monitor cache performance using Epycbyte's analytics tools.

Summary

Epycbyte's Edge Network provides a powerful way to optimize content delivery through caching. By configuring epycbyte.json, leveraging Epycbyte Functions, and setting appropriate headers, you can control how your content is cached, stored, and delivered to users worldwide.

For further reading, explore Epycbyte's official documentation or contact their support team for assistance with specific configurations.