Cache-Control, ETag, and Vary: How the HTTP Cache Works Between Client, Proxy, and Server
Table of contents
- Introduction: why cache control matters more than it seems
- The basics: three participants and two questions
- Deep dive: how a cache makes a decision
- Method 1: designing a freshness policy
- Method 2: validation with etag and conditional requests
- Method 3: vary and cache key management
- Method 4: the http cache and the proxy layer in data collection
- Common mistakes: what not to do
- Tools and resources
- Cases and results
- Faq: deep questions about cache control
- Conclusion: freshness as a controllable parameter
Introduction: why cache control matters more than it seems
If you ask a developer what the Cache-Control header does, most will answer: “it tells the browser how long to keep a file.” That's true, but only about a third of the story. The full picture is more complex and more interesting. Cache control (in the broad sense, HTTP cache management) is a contract between three parties: the client, the intermediary, and the server. And each party reads that contract in its own way.
We've already covered response compression: that was about the number of bytes. Here the axis is different — freshness. Not “how much does the response weigh,” but “can we skip requesting it altogether.” This is a fundamentally different kind of savings: the fastest request is the one that never happened. The cheapest traffic is the traffic that never crossed the network.
Why is this topic so relevant right now? Because there are more intermediary layers than ever. Between your code and the target server there might be a CDN, a corporate proxy, a caching reverse proxy, a service worker in the browser, and, if you're in the data collection business, a rotating proxy port with a periodically changing IP. Each layer can store a copy of the response. Each one can serve it instead of live content. And if you don't manage this deliberately, you get stale data, extra requests, or both.
In this guide you'll learn how the HTTP freshness model actually works, how a shared cache differs from a private one, what a cache key is and why the Vary header can turn a cache into a useless waste of memory. We'll dig into validation via ETag and conditional requests, look at how proxies between client and server behave, give you ready-made frameworks for choosing a strategy, and separately discuss what caching looks like from the perspective of someone scraping sites through rotating proxies. This is the kind of material you bookmark and come back to.
The basics: three participants and two questions
Let's start with the model you should always keep in mind. The HTTP cache answers only two questions, but it answers them at every node along the path.
- The freshness question: can I serve the stored copy right now without contacting the origin?
- The validation question: if the copy is no longer considered fresh, can I cheaply check whether it has changed instead of doing a full re-download?
Everything else — directives, headers, dates — is just a way of answering those two questions.
Who caches
There are three participants, and each has its own role.
- The client — a browser, a mobile app, an HTTP library in your scraper. It has a private cache: storage for a single user. Personal data can go here.
- The intermediary — a CDN, a reverse proxy, a corporate forward proxy. It has a shared cache: one copy serves many. Personal data must not go here, and that's exactly why the private and public directives exist.
- The server — the source of truth. It doesn't cache in the HTTP sense, but it defines the policy: it sets Cache-Control, ETag, Last-Modified, Vary.
An analogy: imagine a newspaper stand (the proxy) between the printing press (the server) and the reader (the client). The press prints a date on the paper and a note saying “valid until this evening.” The stand sells copies from its stock while the note is valid, and then calls the press: “is there a new issue?” If not, it keeps selling the old one. The reader, having bought the paper, doesn't rush back for a new one every five minutes either. That's the HTTP cache in three layers.
Freshness versus validation
The two mechanisms work differently and deliver different savings.
Freshness saves everything: not a single byte over the network, not a single call to the server. The response comes from local storage. That's maximum savings, but at the cost of risking stale content.
Validation saves the response body but not the round trip. The client sends a conditional request with an If-None-Match header (based on ETag) or If-Modified-Since (based on date). The server responds either with 304 Not Modified and an empty body, or with 200 and the new content. There's a request, there's latency, but no heavy body.
A smart policy combines both mechanisms: short or long freshness plus validators for when freshness expires.
The minimal header set
Five are enough to understand the basics:
- Cache-Control — the main policy directive, both in responses and requests.
- Expires — the legacy way to set an absolute expiration date. It loses to max-age when both are present.
- ETag — an opaque identifier for the version of a resource.
- Last-Modified — the date of the last change, the second validator.
- Vary — a list of request headers the response content depends on; it participates in building the cache key.
If you see a response without Cache-Control and without Expires, don't assume it isn't cached. A cache is allowed to apply heuristics: compute a freshness lifetime from the difference between Date and Last-Modified. We'll cover this in detail later, because heuristics are the most common source of surprises.
Deep dive: how a cache makes a decision
Time to break down the algorithm. The modern HTTP caching specification (RFC 9111) describes it fairly strictly, and understanding this logic eliminates most “magical” bugs.
Step one: can the response even be stored
The cache checks several conditions. The request method must be cacheable (in practice GET and sometimes HEAD). The response code must be one the cache understands. There must be no no-store directive. For a shared cache, there must be no private. If the request included Authorization, a shared cache refuses to store the response by default unless the server explicitly allowed it via public, must-revalidate, or s-maxage. Finally, the response must either contain explicit cacheability signals (max-age, s-maxage, Expires, public) or have a code for which heuristics are allowed (for example, 200, 203, 301, 404, 410).
An important detail people miss: no-cache does not prevent storage. That directive means “store it, but ask the server before every use.” The prohibition on storage is no-store. Confusing the two is a classic.
Step two: calculating age
A stored response has an Age — how many seconds it has spent in caches since it was generated. Intermediaries are required to pass along and increment the Age header, so the client gets an honest estimate. Age is the sum of time spent in previous caches, transfer delay, and time spent in the current cache.
The corollary: if you see Age in a response, that's a signal you're looking at a copy from an intermediary. For a scraper that needs live data, it's a marker saying “I got something different from what the server is generating right now.”
Step three: calculating the freshness lifetime
The priority order is:
- For a shared cache — s-maxage, if present.
- Otherwise max-age.
- Otherwise the difference between Expires and Date.
- Otherwise, if allowed, heuristics: usually a fraction of the interval between Date and Last-Modified. Many implementations take a tenth of that interval.
A response is fresh as long as its age is less than the freshness lifetime. Once the age exceeds the lifetime, the response becomes stale. A stale response is not thrown away! It stays in the cache and can be used: either after successful validation, or directly if the directives allow serving stale content (stale-while-revalidate, stale-if-error), or if the origin is unreachable and there's no must-revalidate.
Step four: the cache key
This is the most underrated element. To find a stored response, the cache builds a key. The base key is the method plus the full URL (scheme, host, path, query string). But if the response included Vary, the key is extended: the values of the listed request headers are appended. A response with Vary: Accept-Language will be stored separately for ru-RU and for en-US. A response with Vary: * will never be reused.
The cache key is the reason why the same page can have dozens of copies, and the reason why “I set max-age but I'm not getting cache hits.” We'll cover this separately in the Vary section.
The request controls the cache too
Cache-Control exists not only in responses. A client can send:
- Cache-Control: no-cache in a request — “don't give me a copy without validation.” This is how a normal page reload works in a browser.
- Cache-Control: no-store — “don't store the request or the response.”
- Cache-Control: max-age=0 — “the copy must be no older than zero seconds,” practically the same as no-cache.
- Cache-Control: max-stale=N — “I'll accept a copy that's stale by no more than N seconds.” The opposite situation: the client itself asks for old data for the sake of speed.
- Cache-Control: only-if-cached — “serve only from the cache, don't go to the network.” If there's no copy, you'll get a 504.
For an engineer scraping sites through proxies, request directives are a key tool. An intermediary that follows the spec is required to honor them. If you need guaranteed-fresh data, add no-cache to the request. If you want savings and a slight delay in the data is acceptable — the opposite, allow max-stale.
Method 1: designing a freshness policy
The first practical approach is to determine how long a response can live without a check. This isn't a single number; it's a classification of resources.
Four classes of resources
We suggest dividing everything the server serves into four classes.
- Immutable artifacts: files with a hash in the name (app.a1b2c3.js). The content never changes under the same URL. Policy: maximum max-age, immutable directive, public.
- Slowly changing content: articles, product cards, documentation pages. Policy: moderate max-age or s-maxage plus mandatory validators (ETag or Last-Modified), stale-while-revalidate for smoothing.
- Frequently changing but not personal: news feeds, exchange rates, stock levels. Policy: short s-maxage on the shared cache, no-cache or max-age=0 for the client, validators mandatory.
- Personal or sensitive: account pages, shopping carts, responses with tokens. Policy: private or no-store, depending on whether storage on the device is acceptable at all.
Response directives you need to know
- max-age=N — freshness for N seconds for any cache.
- s-maxage=N — freshness only for the shared cache, overrides max-age on proxies and CDNs. Lets you keep content on a CDN longer than in the browser.
- public — explicit permission for the shared cache to store the response, even if the request was authorized.
- private — storage allowed only in the client cache.
- no-cache — storage is allowed, but use without validation is not.
- no-store — don't store at all.
- must-revalidate — after freshness expires, stale content cannot be served even if the origin is unreachable.
- proxy-revalidate — same, but only for the shared cache.
- immutable — a hint to the client: don't make conditional requests even on a page reload while the response is fresh.
- stale-while-revalidate=N — after freshness expires, the stale copy can still be served for another N seconds while it's being updated in the background.
- stale-if-error=N — on an origin error, stale content can be served for another N seconds.
Step-by-step selection framework
Ask yourself five questions in order.
- Does the response contain personal data? Yes — private or no-store, stop here. No — move on.
- Does the content change under the same URL? No — large max-age, immutable, public. Yes — move on.
- How many seconds of staleness is acceptable to the user? That's your max-age. For the shared cache you can set a separate, usually larger s-maxage, because an intermediary is easier to invalidate centrally.
- What should happen after freshness expires: show stale content and update in the background (stale-while-revalidate) or check for sure (must-revalidate)? The answer depends on the cost of an error.
- Does the resource have a reliable validator? If not, add an ETag. Without a validator, every freshness expiration turns into a full reload.
Example policies
For a hashed bundle:
Cache-Control: public, max-age=31536000, immutableFor an article page that may change after an editor's edits:
Cache-Control: public, max-age=60, s-maxage=600, stale-while-revalidate=120Here the browser keeps a copy for a minute, the CDN for ten minutes, and after expiration it serves the old one for another two minutes while updating.
For an API response with personal data:
Cache-Control: private, no-cacheStorage on the device is allowed, but check with the server before each display. This makes conditional requests possible and saves the response body without risking showing someone else's data.
Freshness policy checklist
- Every resource type has an explicit Cache-Control; heuristics aren't being used by accident.
- Expires doesn't contradict max-age (or is simply absent).
- Responses to authorized requests explicitly specify private or public.
- A separate s-maxage has been considered for the shared cache.
- Resources with validators use no-cache rather than no-store, if storage is acceptable.
- Immutable files have URL versioning and immutable.
Method 2: validation with ETag and conditional requests
The second approach answers the question “what do we do when freshness runs out.” The answer: don't re-download, ask.
Two validators
Last-Modified — the modification date with one-second precision. Simple but weak: if a resource changed twice within a second, the cache won't notice. And it doesn't apply to responses generated dynamically without a single “file” behind them.
ETag — an arbitrary quoted string the server treats as a version identifier. It can be a hash of the content, a revision number, a combination of inode and time. The client doesn't care what's inside; only string comparison matters.
An ETag can be strong ("abc123") or weak (W/"abc123"). A strong tag asserts byte-for-byte identity. A weak tag asserts semantic equivalence: the content is “the same in meaning,” but the bytes may differ. This distinction is critical for Range requests (resuming a partial download requires a strong tag) and becomes a trap with on-the-fly compression: if a server changes the response bytes without changing the strong ETag, it's violating the spec. Correct servers in this case either switch to a weak tag or add a suffix.
How a conditional request works
The sequence looks like this:
- The client receives a response with ETag: "v42" and Last-Modified.
- Freshness expires (or was zero due to no-cache).
- The client repeats the request, adding If-None-Match: "v42" (and, optionally, If-Modified-Since with the saved date).
- The server compares. If the current version matches — it responds with 304 Not Modified without a body, with updated freshness headers. The cache updates the metadata and keeps using the old body.
- If the version changed — it responds with 200 and a new body and a new ETag.
Note: a 304 carries not only the fact “unchanged” but also fresh values of Cache-Control, Date, and Expires. This is how the cache extends the copy's life without re-downloading it. That's the main savings of validation.
If-None-Match takes priority over If-Modified-Since: if both are present, the server checks the ETag first. That's why a reliable server implementation must handle the ETag, not just the date.
Proxies validate too
An intermediary does exactly the same, but on its own behalf. When a shared cache's freshness expires, it sends a conditional request to the origin itself and, upon receiving a 304, extends the copy for all clients at once. And if a client arrives with its own If-None-Match matching the tag of the copy in the proxy, the proxy can respond 304 to the client itself without contacting the origin at all. Three levels, and a shortcut is possible at each.
Validation from a scraper's perspective
This is where it gets really practical. If you regularly scrape the same set of URLs (price monitoring, change tracking, indexing), conditional requests are your best friend. The mechanics of the savings are simple: on a repeat crawl you store the ETag and Last-Modified of each URL, send them in headers, and get an empty body wherever nothing has changed. The more stable the target content, the higher the share of short responses and the less incoming traffic. Outgoing traffic barely grows: conditional headers weigh only bytes.
It's important to understand the flip side too. If the target server generates an ETag on the fly from unstable content (for example, it includes a timestamp or a random session identifier in the page), the tag will change on every request and you'll always get a 200. That's not a cache bug; it's a property of the origin. Diagnosis: request the URL twice in a row without conditions and compare the ETag. If it differs while the content is equivalent, validation for that URL is useless, and it's worth switching to If-Modified-Since or comparing the content yourself.
Step-by-step implementation of conditional crawling
- Set up storage (key — normalized URL; values — ETag, Last-Modified, the body or its hash, the time of the last successful response).
- On a request, if there's an ETag in storage, add If-None-Match. If there's only a date — If-Modified-Since.
- On 304 — update the time and take the body from storage. On 200 — save the new body and the new validators.
- If the target server responds 200 with the same ETag you sent, it ignores conditional headers. Flag the domain and don't waste effort.
- If you're going through a proxy, remember: the 304 may come from an intermediary, not the origin. For verification it's sometimes useful to make a control request with Cache-Control: no-cache.
Server-side validation checklist
- Every cacheable response has an ETag or Last-Modified (ideally both).
- The ETag is stable when content is unchanged and deterministic across server replicas.
- The server correctly handles If-None-Match with a list of tags and the asterisk wildcard.
- A 304 is returned with up-to-date Cache-Control, ETag, Vary, Date.
- Responses that are dynamically compressed use a weak tag or a modified strong one.
Method 3: Vary and cache key management
The third approach is control over how many copies of a resource will exist and whether they'll be found at all.
Why Vary is needed
The same URL can return different content depending on request headers: language (Accept-Language), format (Accept), encoding (Accept-Encoding), device type. If the cache doesn't know this, it will serve a Russian-language page to a user with an English browser. Vary tells the cache: “when looking for a copy, also consider these headers.”
For the cache this means the key consists of the URL plus the values of the listed headers. A copy stored for Accept-Language: ru won't match Accept-Language: en. There will be two entries. That's correct and useful.
Where Vary breaks the cache
The problem is cardinality: the number of distinct values of a header. Accept-Language has moderate cardinality. But Vary: User-Agent is a disaster. There are thousands of User-Agent strings: browser versions, OS builds, mobile wrappers. Each unique value creates a separate cache entry. Hits become rare, memory is wasted, and in effect you get a cache that's almost never used, even though everything is formally configured.
Vary: Cookie is even worse. Cookies are almost always unique per user, which means a shared cache turns into a collection of one-off entries. If the response really does depend on a cookie, the right choice is private, not Vary: Cookie.
Vary: * is the extreme case: “the response depends on something I can't express.” Any cache is required to treat such a copy as unusable for reuse.
Normalization as the rescue
The solution to the cardinality problem is normalization at the edge. An intermediary (CDN, reverse proxy) reduces the incoming header to a small set of classes before contacting the server. Thousands of User-Agents become two or three values: mobile, desktop, bot. Dozens of Accept-Language variants become a list of supported languages with one fallback. The server receives an already normalized header and sets Vary by it. Cardinality drops to single digits, and the cache starts working.
The same idea applies to Accept-Encoding: instead of an arbitrary string of codecs in arbitrary order, the edge keeps the single best supported value. We won't go deep into compression — there's a separate article for that — but in the context of the cache key this header behaves like any other: its variety multiplies copies.
Vary and the proxy between you and the origin
Now let's look at it from the other side. You're the client, requests go through an intermediary, and the target server has set Vary: User-Agent. What happens if you change User-Agent from request to request? Each variant becomes a separate key. The intermediary's cache can't help you, and every request goes to the origin. Sometimes that's exactly what you want (for example, you want to see how the origin serves the page to different devices). Sometimes it's extra load. The takeaway: variability in request headers is worth planning deliberately, knowing that each unique combination is a separate copy in every cache along the path.
The reverse trick: if you want to get exactly the live response rather than a copy from the intermediary's cache, you can rely on the request directive Cache-Control: no-cache. This is the honest, protocol-sanctioned way, and it works better than trying to “break” the cache key with random URL parameters.
Step-by-step Vary setup on the server
- Make a list of the request headers the response body actually depends on. Not “just in case,” but in fact.
- Estimate the cardinality of each. High — normalize at the edge or remove the dependency.
- If the dependency is on the user — replace Vary with private.
- Set Vary in both 200 and 304 responses: the spec expects consistency.
- Verify that Vary is the same on all server replicas; a discrepancy leads to unpredictable keys.
Vary checklist
- Vary doesn't contain User-Agent without normalization.
- Vary doesn't contain Cookie; personal content is marked private.
- Vary: * isn't used in cacheable responses.
- The headers listed in Vary are normalized at the edge.
- The query string doesn't contain junk parameters that multiply keys (tracking labels should be dropped at the edge).
Method 4: the HTTP cache and the proxy layer in data collection
The fourth approach is dedicated to the situation where the intermediary is not your CDN, but an external proxy through which sites are scraped. Here caching is both a tool and a source of errors.
What IP rotation changes
A rotating proxy port is an entry point behind which the exit address changes periodically. In Proxeon's infrastructure, IP changes on a port happen in two ways: on a timer or via a link/API (as of 22.09.2026). The choice of method affects how the target server's cache and intermediaries along the path treat your requests.
The scale of rotation is noticeable: in 24 hours, 7,924 proxy ports changed IP (as of 14.11.2026). At the same time, 51.1% of changes were on a timer and the rest via link/API (as of 14.11.2026), and the median interval between timer-based changes was 120 s (as of 14.11.2026). Two minutes is an important reference point. If the freshness lifetime of the response you receive is comparable to or longer than the rotation interval, the same copy can “outlive” an address change. That's neither good nor bad in itself, but it needs to be taken into account.
How IP affects the cache
Strictly by the spec, the client IP is not part of the cache key. Vary lists headers, and the address is not a header. That's why a shared cache on the target site's side (its CDN) serves the same copy to everyone who sent the same URL and headers, regardless of address. Changing IP by itself doesn't “refresh” content for you. If you need fresh data after rotation, you need a no-cache request directive or you need to wait for freshness to expire — not a new address.
But there's a nuance: some servers include geographic or network attributes determined by address in the response content (currency, local prices, regional stock levels). Formally, such a response doesn't depend on headers, and Vary doesn't describe it. If it's cached on a CDN with a long s-maxage, a user from a different region may receive a copy generated for the first address. For a scraper, this means: when crawling with rotation, you may see a “smeared” picture of regions — and not because of your mistake, but because of the origin's cache. Check: compare responses with and without Cache-Control: no-cache; if they differ, the origin's cache is interfering.
Two crawling modes
We distinguish two modes of working with the cache in data collection.
Savings mode. The goal is minimum traffic and load. We use conditional requests (If-None-Match, If-Modified-Since), don't interfere with intermediary caches, allow max-stale where relevance is secondary. Suitable for monitoring rarely changing pages, catalogs, documentation.
Accuracy mode. The goal is a guaranteed live response. We add Cache-Control: no-cache and Pragma: no-cache (the latter for older nodes), ignore the cache, and monitor Age in the response. Suitable for prices, stock levels, statuses — anything where stale data costs more than an extra request.
Mixing modes within one task should be deliberate: conditional headers and no-cache combine perfectly (the server will check the ETag and return 304 if nothing has changed, but the check will be live), while max-stale and no-cache contradict each other.
Changing IP on a timer or via API
For the cache, the difference between the two rotation methods comes down to predictability. Timer-based changes give a regular grid; the median interval of 120 s (as of 14.11.2026) lets you plan in advance which requests will fall on one address. Link/API-based changes give you control: you change the address exactly when the task logic requires it — for example, after finishing a session with one set of cookies so as not to mix personalized copies. For strategies where it's important that a series of conditional requests to one host goes through within one address, API rotation is more convenient: you set the boundary yourself.
Step-by-step crawling scheme with caching in mind
- Determine the mode for the task: savings or accuracy.
- Normalize URLs before writing them to the validator storage: remove tracking parameters, standardize parameter order.
- Fix the set of request headers for the duration of the task. Every change to User-Agent or Accept-Language is a new key in the caches along the path.
- In savings mode, send If-None-Match; in accuracy mode, add Cache-Control: no-cache.
- Read Age and Cache-Control in the response. A large Age when you expect live data is a signal to review the headers.
- Decide when to change IP: on a timer for uniform load, via API to tie the change to logical session boundaries.
- Log 200 and 304 codes per host. The ratio will show where validation works and where the origin ignores it.
Proxy layer checklist
- The crawling mode is chosen explicitly and reflected in the request headers.
- The validator storage is tied to the normalized URL, not the raw string.
- The header set is stable within the task.
- Age is monitored and logged.
- The rotation method is consistent with the session logic.
Common mistakes: what NOT to do
Let's collect the mistakes that occur most often, with an explanation of why they're harmful.
Confusing no-cache and no-store
no-cache allows storage and requires validation; no-store prohibits storage. By setting no-store “to be safe” on ordinary pages, you disable conditional requests and force every client to download the full body on every visit. By setting no-cache on something truly secret, you leave a copy on the client's disk and in intermediaries.
Relying on heuristics
A response without Cache-Control and without Expires is not “uncacheable.” It's a response whose freshness lifetime the cache will determine at its own discretion based on Last-Modified. A page that hasn't changed in a year can get a heuristic freshness of weeks. You edit it, but users and proxies keep seeing the old version. Always set the policy explicitly.
Vary: User-Agent without normalization
We've covered this: cardinality kills hits. Either normalize or remove it.
Unstable ETag
If the ETag is built from fields that differ between replicas (file path on disk, inode, local time), the same resource will get different tags on different servers behind the load balancer. The client sends If-None-Match with the first replica's tag, lands on the second, and gets 200 instead of 304. Validation formally exists but doesn't actually work. Generate the tag from the content or from the version in the data store.
Changing content under an immutable URL
If you've set immutable and a year-long max-age and then update a file with the same name, some users will only see the update in a year. The only solution is URL versioning.
Caching personal content at the shared level
A response to an authorized request without private can end up in a shared cache if the server accidentally added public or s-maxage. The result: one user sees another's data. This isn't hypothetical; it's one of the most painful classes of incidents. The rule: personal content is always private, and this must be checked automatically.
Breaking the cache key with random parameters
Adding a random parameter to the URL for “freshness” (cache busting in the request) clogs intermediary caches with useless entries and interferes with your own validator storage. For a live response there's the no-cache request directive.
Ignoring Age
If you think you got a live response but it has Age of hundreds of seconds, you're mistaken. Check it.
Returning a 304 without updated headers
A 304 must carry up-to-date Cache-Control, ETag, Vary. Without them the cache can't correctly extend the copy, and validation will repeat on every visit.
Not aligning Vary between 200 and 304
A discrepancy means the cache can't match the validated response with the stored copy and simply re-requests.
Tools and resources
You don't need much to work with the HTTP cache, but what you need is worth knowing well.
Command line
curl remains the primary diagnostic tool. Viewing response headers without the body:
curl -sI https://example.test/pageA conditional request by ETag:
curl -si -H "If-None-Match: \"v42\"" https://example.test/pageA request for a live response, bypassing intermediary caches:
curl -si -H "Cache-Control: no-cache" https://example.test/pageA request through a proxy port with conditional headers:
curl -si -x http://host:port -H "If-Modified-Since: Tue, 01 Jan 2030 00:00:00 GMT" https://example.test/pageWatch the response codes, Age, Cache-Control, ETag, Vary. Compare two consecutive requests: a different ETag with the same content indicates an unstable validator.
Browser developer tools
The network tab shows where the response came from: from memory, from disk, via 304, or a full 200. It's useful to disable the cache and turn it back on to see the difference. Pay attention to behavior on a normal reload (request no-cache) and on a hard reload (ignoring the cache entirely).
Server implementations
- nginx — the expires, add_header Cache-Control, etag on/off directives, and in reverse-proxy mode — proxy_cache with proxy_cache_key, proxy_cache_revalidate (conditional requests to the origin), proxy_cache_use_stale (analogous to stale-while-revalidate and stale-if-error), proxy_cache_background_update.
- Varnish — the VCL language lets you normalize headers before forming the key, override TTL, set grace (stale content when the origin is unreachable), and implement background updates.
- Apache — the mod_cache and mod_expires modules, FileETag for controlling the tag composition.
- Service workers in the browser — a programmable cache on top of the HTTP cache; it's a separate layer with its own rules that's easy to confuse with the HTTP cache during debugging.
Libraries for clients and scrapers
Most HTTP libraries don't implement caching by default; there are add-ons for them that read Cache-Control, store copies, and automatically add conditional headers. If you're writing a crawler yourself, the validator storage and URL normalization discipline described above are all you need.
Specifications
The current documents: RFC 9110 (HTTP semantics, including conditional requests and validators), RFC 9111 (caching), RFC 5861 (stale-while-revalidate and stale-if-error), RFC 8246 (immutable). Reading these texts pays off: most cache “oddities” are strict adherence to the spec, not bugs.
Proxeon working artifacts
For crawling through rotating ports, two facts about our infrastructure matter: the rotation methods (on a timer or via link/API, as of 22.09.2026) and the median timer-based interval of 120 s (as of 14.11.2026). Use the interval as a reference point when planning series of conditional requests to one host.
Cases and results
Below are typical scenarios in which deliberate cache management changed system behavior. We describe the mechanics and the observed effect without citing numbers that aren't in the verified data.
Case 1: a product catalog and conditional crawling
The task was to track changes daily in a large catalog where most cards don't change for weeks. Before conditional requests, each crawl downloaded the full HTML of every card. After: a validator storage keyed by normalized URL, If-None-Match in every request, 304 handling. Effect: where a card hadn't changed, no body was transmitted, the crawl got faster, and the load on the origin decreased. We separately identified domains that answered 200 to any conditional request; for them we enabled content-hash comparison on our side. Lesson: conditional requests are free for you and respectful to the origin, but they require verifying that the validator is stable.
Case 2: regional prices and the origin's cache
The team was collecting prices for several regions, changing the exit address via API rotation before each regional series. Some prices looked implausibly identical across regions. Diagnosis with request no-cache showed: the origin was serving regional prices from its CDN's shared cache, where a copy generated for the first region served the others for the length of the s-maxage. Solution: for accuracy mode we added no-cache, and spread the regional series out in time beyond the freshness lifetime. Lesson: changing IP doesn't invalidate the origin's cache; live data needs a directive, not an address.
Case 3: Vary: User-Agent and an empty reverse-proxy cache
The web service set Vary: User-Agent to correctly serve mobile and desktop versions. The reverse-proxy cache practically never got hits — every browser version created its own entry. Fix: normalizing User-Agent at the edge to two classes and Vary by the normalized value. Lesson: Vary solves the correctness problem, but without normalization it creates an efficiency problem.
Case 4: unstable ETag behind a load balancer
Static files were served from several replicas, and the default ETag included file system metadata. Clients got 200 instead of 304 roughly when the repeat request landed on a different replica. Fix: a tag from the content hash, the same on all replicas. Lesson: the ETag must be deterministic by content, not by storage location.
Case 5: heuristics and a page that “won't update”
An editorial page without explicit Cache-Control hadn't changed for years, and then it was rewritten. Users and intermediaries kept seeing the old version because the heuristic freshness computed from the long-ago Last-Modified turned out to be long. Fix: explicit max-age with validators and stale-while-revalidate. Lesson: the absence of a policy is also a policy, and usually a bad one.
Case 6: timer-based rotation and a series of conditional requests
The crawler sent sequences of conditional requests to one host through a port with timer-based rotation. The median interval of 120 s (as of 14.11.2026) meant that a long series crossed an address change. For origins where it didn't matter, we kept the timer — a regular grid simplified planning. For origins sensitive to session consistency, we switched to link/API-based changes at the end of each series. Lesson: the rotation method is part of the caching strategy, not an independent setting.
FAQ: deep questions about cache control
What's the difference between s-maxage and max-age, and when do you need both?
max-age applies to all caches, s-maxage only to shared ones (proxies, CDNs) and overrides max-age there. Both are needed when you want the CDN to keep a copy longer than the browser: the CDN is easy to invalidate centrally, the user's browser is not. A short max-age for the client plus a long s-maxage for the CDN is a common and reasonable combination.
Why does a response with no-cache still end up in the cache?
Because no-cache means “don't use without validation,” not “don't store.” The copy is saved, and on the next visit the cache sends a conditional request. If the server returns 304, the copy will be used. That's exactly the behavior that makes validation useful. If you can't store it at all, use no-store.
Can you trust Last-Modified if there's an ETag?
If both are present, the client sends both conditional headers, and the server must check If-None-Match first. Last-Modified remains useful for older nodes and for cases where the ETag is unavailable. But deciding whether a copy is current based only on the date is risky: one-second precision and dependence on the server's clock make it a weak validator.
Does changing IP on a proxy change the content of a cached response?
No. The address isn't part of the cache key, which is built from the URL and the headers listed in Vary. The origin's shared cache will serve the same copy if the request matched the key. If you need a live response, use the request directive Cache-Control: no-cache. Changing the address on a timer or via link/API (as of 22.09.2026) is a tool for managing sessions and load, not for invalidating the cache.
How can you tell the response came from an intermediary cache rather than the server?
Look at the Age header: a non-zero value means the copy has spent time in a cache. Some nodes add their own diagnostic headers with hit markers. The reliable way is to send the same request with Cache-Control: no-cache and compare the responses.
What should you do if the target server ignores If-None-Match?
Check that you're sending the tag exactly as you received it, including quotes and the W/ prefix. If the format is correct and the server still responds 200, it doesn't implement conditional requests. Switch to If-Modified-Since or to comparing the body hash yourself. Flag the domain so you don't waste extra headers.
Is it dangerous to use stale-while-revalidate?
It's only dangerous where stale data is expensive. For articles, catalogs, and documentation it's an almost ideal directive: the user doesn't wait, and the cache updates in the background. For prices and stock levels, choose must-revalidate or a short max-age. The main thing is that the staleness window is deliberate.
Why is the page being cached even though I didn't set Cache-Control?
Because of heuristics. With Last-Modified present and a cacheable response code, the cache is entitled to compute the freshness lifetime itself. The older the change, the longer the freshness. The only way to control this is an explicit policy.
Should I change request headers when crawling through a proxy to “refresh” the cache?
Changing a header that's included in Vary will create a new key and probably result in a call to the origin, but that's a side effect, not a tool. The correct tool is the no-cache or max-age=0 request directive. Random URL parameters and chaotic headers clog caches and interfere with your own validator storage.
How do you combine timer-based rotation with caching?
Go by the interval: the median for timer-based changes is 120 s (as of 14.11.2026). If a series of requests to one host fits within that interval, it will go through from one address. If not — either split the series or use link/API-based changes so you set the boundaries yourself. The origin's cache behaves the same either way: it looks at the URL and headers, not the address.
Conclusion: freshness as a controllable parameter
Let's sum up. Cache control isn't a checkbox that says “cache or don't cache”; it's a full system with three participants, two questions, and a set of directives that answer those questions at every node. Freshness determines whether you can skip the network altogether. Validation determines whether you can make a cheap trip. The cache key and Vary determine whether a copy will be found at all. The proxy layer adds the logic of its own shared cache and, with address rotation, its own planning quirks.
What should you do next? Here's a five-step sequence.
- Audit your server's responses: every resource type must have an explicit policy, not heuristics.
- Make sure the validators are stable and deterministic; verify that a 304 is actually returned when content is unchanged.
- Revisit Vary: remove high-cardinality headers or normalize them at the edge; move personal content to private.
- If you collect data through proxies — choose a mode for each task, implement validator storage, and monitor Age in responses.
- Align the rotation method with session logic: a timer for uniformity, the API for controlled boundaries.
A well-designed cache is invisible: pages open instantly, crawlers don't download extra data, origins don't suffer from repeat requests, and the data stays as current as you decided it should be. That's the goal — making freshness a controllable parameter rather than an accident. Bookmark this material, come back to the checklists on your next release, and go through every item. The Proxeon team would be glad if it becomes your desk reference for HTTP caching.