cs-icon.svg

Cache Priming

Cache Priming is a performance optimization feature in Contentstack Launch that improves website speed by preloading critical content into the CDN cache before user access. This proactive caching reduces latency, minimizes server load, and ensures seamless content delivery.

Ideal for high-traffic websites, e-commerce platforms, and content-heavy applications, Cache Priming enhances the user experience by accelerating page load times and optimizing resource efficiency.

How Cache Priming Works

Cache Priming preloads pages and content onto the CDN cache during deployment, ensuring the latest versions are immediately available without requiring an initial request. By eliminating delays caused by backend processing or stale cache states, it consistently delivers fresh, optimized experiences.

Overcoming Performance Challenges with Cache Priming

Modern front-end architectures rely on Server-Side Rendering (SSR), Incremental Static Regeneration (ISR), and Dynamic Static Generation (DSG) to serve dynamic content efficiently. However, these techniques can introduce longer build times and delays for first-time visitors. Cache Priming mitigates these issues by preloading critical content during deployment. By decoupling the build process from the user experience, it ensures fast access to pre-cached content, reducing wait times and improving efficiency, especially during peak traffic periods.

Key Benefits of Cache Priming

  • Optimized Performance for High-Traffic Websites: Ensures fast loading of critical pages, preventing server overload and downtime during traffic surges.
  • Seamless E-Commerce Experiences: Preloads promotional and product pages, enabling smooth navigation during major sales events.
  • Enhanced Performance for Content-Heavy Sites: Reduces latency and improves access for media, news, and entertainment platforms.
  • Global Content Delivery: Minimizes geographic latency, providing a consistent experience for users worldwide.
  • Improved User Experience: Pre-caches high-priority content, ensuring instant access for both new and returning visitors.
  • Increased Cache Efficiency: Enhances cache hit ratios, optimizing performance and reducing unnecessary origin requests.
  • Advanced Cache Management: Provides better visibility and control over the caching layer, enabling technical teams to monitor and optimize performance effectively.

Steps for Execution

Follow the steps below to configure and implement Cache Priming in Contentstack Launch:

  1. Add URLs to launch.json

    1. Open your source code folder.
    2. Edit the launch.json file inside the folder by adding the URLs you want to prime. For optimal performance, ensure these URLs are unique and frequently accessed.

    Example for launch.json Configuration:

    {
      "cache": {
        "cachePriming": {
          "urls": [
            "/delay",
            "/blog.html",
            "/new-page.html"
          ]
        }
      }
    }
  2. Deploy your Project in Launch

    Choose one of the following methods to deploy your project in Launch:

  3. Enable Cache Priming in your Project

    Once the project is deployed, follow the steps below:

    1. Click the Settings icon in the left panel.Launch-Cache-Priming-Settings.png
    2. Navigate to Environments > Cache Priming.Launch-Cache-Priming-Env-CachePriming.png
    3. Click the Enable Cache Priming toggle to enable priming.Launch-Cache-Priming-Enable-CachePriming.png

Note: Cache Priming takes effect from the next deployment of your project.

By leveraging Cache Priming, websites can achieve superior speed, reliability, and scalability, ensuring a seamless experience for users across all regions.

Limitations

While Cache Priming helps reduce cold-start latency by preloading key routes into the cache, there are a few important limitations to consider:

  • Only Relative Paths Are Supported:
    The launch.json configuration must use relative paths. Fully qualified URLs are not supported.
    For example, use /home instead of https://example.com/home.
  • No Regex or Wildcards:
    The configuration does not support regular expressions, wildcard characters (*), or glob patterns. You must list each path explicitly.
  • Incompatible with IP-Restricted Sites:
    Cache priming requests originate from platform-managed IP addresses. If your site enforces IP whitelisting, VPN access, or firewall restrictions, these requests may be blocked unless the necessary IPs are allowed.
Was this article helpful?
^