Expand my Community achievements bar.

Edge Delivery Service - Cache

Avatar

Level 1

Hello Team,

 

As I am exploring the capabilities of EDS, want to understand the controlling the cache for pages on EDS. 

 

Tried couple of methods such are having .helix/headers with cache-control header in google drive and following another step of having configuration helix-routes.yaml file in git repo.

 

Both approach dint work for me. Please guide me. 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

4 Replies

Avatar

Community Advisor

Hi @PradeepMC1 ,

 

You can control caching of pages by cache-control header for a cacheable page:

 

Cache-Control: public, max-age=3600, stale-while-revalidate=60
  • public: Indicates that the response can be cached by any cache, including browsers and CDNs.
  • max-age=3600: Sets the cache duration to one hour.
  • stale-while-revalidate=60: Allows serving stale content for up to 60 seconds while fetching fresh content in the background.

 

-Tarun

Avatar

Community Advisor

Avatar

Community Advisor

Hi @PradeepMC1 ,

Pls Follow Below Steps to Control Cache in EDS:

Step 1: Identify Your Project Type

Are you using:

     - Google Drive/OneDrive ➜ Use .helix/headers file
     - GitHub Repo ➜ Use helix-routes.yaml file

Step 2: For Google Drive/OneDrive Projects

     - Create a file named .helix/headers in your drive.

     - Add below lines to control caching for your pages:

/path/to/page.html
  Cache-Control: public, max-age=3600, stale-while-revalidate=60

     - This sets:

            - Cache duration = 1 hour (3600 seconds)
            - Allows stale content for 60 seconds during revalidation

 

Step 3: For GitHub Repo Projects

     - Open your GitHub repo.

     - Create or update helix-routes.yaml in root.

      - Add this configuration:

version: 1
static:
  - path: "/**"
    headers:
      cache-control: "public, max-age=3600, stale-while-revalidate=60"

     - This applies cache to all pages. Modify path as needed (/about.html, /blog/**, etc.)

Step 4: Validate Cache Header is Applied

     - Deploy your site (EDS).
     - Open site in browser ➜ DevTools (F12) ➜ Network tab.
     - Select a page ➜ Check Response Headers.
You should see:

Cache-Control: public, max-age=3600, stale-while-revalidate=60

Step 5: No Cache (Optional)

If you don’t want any caching, use this instead:

Cache-Control: no-cache, no-store, must-revalidate


Regards,
Amit

Avatar

Community Advisor

Hi @AmitVishwakarma 

Could you please share reference document for helix-routes.yaml file, I have not able to find anything on adobe doc ?

 

Step 3: For GitHub Repo Projects

     - Open your GitHub repo.

     - Create or update helix-routes.yaml in root.



Arun Patidar