---
title: "Discussion on \"AWS Lambda@Edge: How to control cache TTL?\" | Hashnode"
description: "Discussion on \"AWS Lambda@Edge: How to control cache TTL?\". Discover the secrets of managing cache TTL with AWS Lambda@Edge. Enhance your site's speed and reliability using Lambda@Edge functions."
url: "https://hashnode.com/posts/aws-lambdaedge-how-to-control-cache-ttl/666f09a8307275a65fc3a604"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [AWS Lambda@Edge: How to control cache TTL?](https://blog.cloudgags.in/aws-lambdaedge-how-to-control-cache-ttl?utm_source=hashnode&utm_medium=feed)

Discover the secrets of managing cache TTL with AWS Lambda@Edge. Enhance your site's speed and reliability using Lambda@Edge functions.

Jun 16, 2024 · 3 min read · blog.cloudgags.in  
Updated Jun 29, 2024  
Read the article

-   [#cache-control](https://hashnode.com/tag/cache-control)
-   [#aws](https://hashnode.com/tag/aws)
-   [#lambda](https://hashnode.com/tag/lambda)
-   [#lambdaedge](https://hashnode.com/tag/lambdaedge)
-   [#cache](https://hashnode.com/tag/cache)
-   [#ttl](https://hashnode.com/tag/ttl)
-   [#edge-locations](https://hashnode.com/tag/edge-locations)

## Written by

[CloudGags](https://hashnode.com/@cloudgags)

@cloudgags

  
[View profile](https://hashnode.com/@cloudgags)

## Responses 2

Markdown supported · ⌘↵ to post

[CDN Edge Ops](https://hashnode.com/@cdnedgeops)

[Nov 5](https://hashnode.com/posts/aws-lambdaedge-how-to-control-cache-ttl/666f09a8307275a65fc3a604/comment/6aec39f0369b0451fc7b5d8b)

Lambda@Edge can rewrite Cache-Control, but CloudFront still decides whether the object is eligible for a shared HIT. Setting a long max-age from viewer-response on a response that also carries Set-Cookie, Authorization, or private/no-store simply stores personalised variants — or forces BYPASS — so origin request rate barely moves. Prefer viewer-request or origin-response hooks that strip cache-busting cookies from public asset paths, emit s-maxage for shared edges, and keep HTML or other non-hashed shells on short TTL (or a purge tag) while content-hashed JS/CSS stay immutable.

Ops prove-out after a Lambda@Edge publish: request the same URL twice from a clean client and compare Age / X-Cache (or the distribution cache-hit metric) with the Cache-Control the edge actually returned. Confirm the function association is on the behaviour you think you edited, and that a second request flips to HIT without the cookie jar from the first. After a deploy that changes headers, watch origin request rate for that host — a flat miss line usually means the cache key still includes a query, method, or Cookie you did not intend, not a broken POP.
