---
title: "Tech Tip #47: Cache at every layer (video)"
description: "Why send the same bytes a million times?"
url: https://greencode.ai/shorts/47-cache-at-every-layer/
---

# Tech Tip #47: Cache at every layer (video)

## Tech Tip #47: Cache at every layer

**Why send the same bytes a million times?**

[Watch the video](https://media.greencode.ai/shorts/cache-at-every-layer-4bc893a3c320.mp4)

Video created by [explainapaper.com](https://explainapaper.com/?utm_source=greencode.ai&utm_medium=film&utm_campaign=made-by)

### The problem

Responses that rarely change are regenerated and re-sent on every request: no cache headers, no CDN, no application cache.

### The fix you can use today

- Set Cache-Control headers on static assets, with long lifetimes and versioned file names.
- Put a CDN in front of static content.
- Cache expensive query results in the application where they can go slightly stale.

GreenCode researchers list missing caches as an energy waste to fix.

### Tools that help

- [GreenCode Constitution skill](https://greencode-constitution.org/?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode) (GreenCode researchers): open-source energy principles and a catalogue of 37 energy anti-patterns that an AI coding agent can follow to find and fix waste like this
- [WebPageTest](https://www.webpagetest.org/?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode): loads a real page and shows every request, its size and when it loaded

### How GreenCode helps

GreenCode helps tackle this by scoring a codebase against quality, security and green software patterns in one pass, so a missing cache comes out as a ranked defect alongside the bugs and security findings. [More on this](https://greencode.ai/feature/sustainability-led-code-quality-assessment/).

### Tags

#caching#cdn#web-performance

### Sources

- [GreenCode Constitution (Kapenekakis et al., GreenAI workshop, ECML PKDD 2026): missing caching layers in Tier 2](https://greencode.ai/publications/greencode-constitution-agent-principles-for-optimizing-code-and-llm-inference-en/)
- [GreenCode Constitution skill, energy anti-patterns: H8 single-layer caching: browser, CDN, application and database](https://greencode-constitution.org/skill.md?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode)
- [Green Software Foundation, Green Software Patterns: Cache static data](https://github.com/Green-Software-Foundation/patterns/blob/main/docs/development/data-handling/cache-static-data.md?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode)
- [HTTP Archive, Web Almanac 2024, Sustainability: caching (about a quarter of sites send no caching headers)](https://almanac.httparchive.org/en/2024/sustainability?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode)
- [W3C, Web Sustainability Guidelines: server-side and client-side caching, cache lifetimes](https://www.w3.org/TR/web-sustainability-guidelines/#caching-resources)

### Transcript

Why send the same bytes a million times? Many responses rarely change. Yet they are rebuilt and sent again on every request. No cache headers, no content delivery network, no cache in the app. Every request not made is energy not spent. On your servers, on the network, and on the user's device. Here is the fix you can use today. First, set cache headers on static files, with long lifetimes. Put a version in each file name, so a change gets a new address. Next, serve static content from a content delivery network. Then cache costly query results in your app, where slightly old data is fine. GreenCode's Constitution skill can help an AI coding agent spot missing caches. And tools like WebPageTest show every request a page makes, and its size. GreenCode researchers list missing caches as an energy waste to fix. GreenCode helps tackle this by scoring code against green software patterns in one pass. A missing cache comes out ranked, alongside bugs and security findings. That was GreenCode Tech Tip number forty-seven. Follow for the next tip, and find more on greencode.ai/tech-tips.

[The tip in full](https://greencode.ai/tech-tips/47-cache-at-every-layer/)

[« Tech Tip #46: Do containers waste energy?](https://greencode.ai/shorts/46-containers-myth/)[Tech Tip #48: Don't buy availability you don't need »](https://greencode.ai/shorts/48-dont-buy-availability-you-dont-need/)

[All GreenCode Tech Tips](https://greencode.ai/tech-tips/) · [All GreenCode videos](https://greencode.ai/videos/)

#### Key Facts

- Tip **#47**
- For **Developers**
- Length **1:14**
- Category **Web and front-end**
![GreenCode](https://greencode.ai/wp-content/uploads/2024/12/greencode-logo-website-small-colours-2.webp)

Want this checked on your own system? Talk to the GreenCode team.

[Get in touch](https://greencode.ai/contact/)
