Skip to main content

Cache — content caching

Cache lets VNIS keep copies of your content on the edge nodes, so later requests are served directly from the edge instead of going back to the origin (origin server). The result: faster page loads and less load on the origin.

Use this when: pages/resources change infrequently (images, CSS/JS, product pages, articles). Example: your shop has 10,000 product images — enable caching so the images are served from the edge and the origin does not have to handle every view.

There are 2 levels:

  • Cache Settings — the default configuration for the whole domain (TTL, cache key, Vary).
  • Cache Policy (path-based cache rules) — overrides for specific paths (see Example: Cache Policy — path rules).

Before you start​

  • You have added and verified the domain and pointed the CNAME to VNIS.
  • You have configured the Origin/Upstream (origin server) for the domain.

How to: Cache Settings​

  1. Go to Domains → select the domain → Cache tab. Go to Domains → select the domain → Cache tab
  2. Turn on the Enabled switch.
  3. Set the Default TTL (default cache duration), for example 3600 seconds (1 hour).
  4. (Optional) Open Cache Key to choose how VNIS distinguishes cached copies (by query string, header, cookie…).
  5. Click Save. Wait a few seconds for the configuration to sync to the nodes.

Fields: Cache Settings​

FieldMeaningValuesDefaultNotes
EnabledTurns caching on/off for the domainOn/offOnOff = every request goes to the origin
Bypass cacheSkips the cache (always goes to the origin)On/offOffUse for debugging
Default TTLDefault cache durationSeconds, ≤ 31,536,0003600Applies when the origin does not specify one
Max TTLMaximum cache duration (ceiling)Seconds, ≤ 31,536,0002,592,000Must be ≥ Default TTL
Edge TTLSeparate TTL at the edgeSeconds (0 = use default)0If >0, must be ≤ Max TTL
Browser TTLTTL sent to the browserSeconds (0 = not set)0≤ Max TTL
Stale while revalidate (SWR)Keeps serving the old cached copy while a new copy is fetched in the background (SWR — stale-while-revalidate)Seconds0Reduces latency on expiry
Stale if errorAllows serving the old copy when the origin failsSeconds0Improves fault tolerance
Status TTLTTL per HTTP status codeMap {code: seconds}, ≤500 entries—Codes 100–599, 0–86400
Cache Key › Query strategyHow the query string is handled in the cache keyall / none / include / excludeallinclude/exclude are used with a parameter list
Cache Key › Query paramsList of parameters for include/exclude≤50 parameters——
Cache Key › Sort querySorts the query to increase the cache match rateOn/offOn—
Cache Key › Header/Cookie includeAdds headers/cookies to the cache key≤16 of each type—More keys → fewer matches
Vary › AllowlistList of headers that create cache variants≤8—Many variants reduce cache efficiency

Ignore client no-cache determines whether the edge ignores Cache-Control: no-cache / Pragma: no-cache sent by the browser/client. On (default) = the cached copy is still returned (CDN mode); Off = the client's request is honored and the request goes to the origin. Order of evaluation: if the request matches a Cache Policy rule → that rule's Ignore no-cache client value is used; if no rule matches → the value at the domain level here is used; if the domain has no cache configuration → the system-wide configuration is used. New domains and new rules both default to On.

Example: Cache Policy — path rules​

Cache Policy lets you set separate rules for each path. Rules have a priority: lower numbers run first, and evaluation stops at the first matching rule.

Example 1 — Cache static images for 7 days.

  • Condition: url_path starts_with /assets/
  • Set: Edge TTL = 604800 (7 days).
  • Expected result: images in /assets/ are served from the edge, and the response includes X-Cache: HIT (if Enable X-Cache is on).
  • How to check: curl -I https://example.com/assets/logo.png a second time → you see X-Cache: HIT.

Example 2 — Do not cache the API.

  • Condition: url_path starts_with /api/
  • Turn on: No cache.
  • Result: every /api/* request always goes to the origin and is not stored at the edge.
  • How to check: call /api/... several times → always X-Cache: MISS/never a HIT.

Example 3 — Force caching of product pages even when the origin returns no-cache.

  • Condition: url_path starts_with /products/
  • Turn on: Ignore no-cache origin (forces caching, ignoring the origin's Cache-Control: no-cache directive).
  • Result: product pages are cached for the Edge TTL you set.
  • Warning: only force caching of content that is public and the same for everyone. Do not force caching of pages with per-user data (shopping cart, account) — this would expose one user's data to another. VNIS still keeps some "safety floors" (no caching when Authorization or Set-Cookie is present…), but you still need to limit the rule to the correct paths yourself.
  • How to check: run curl -I twice → the second time shows X-Cache: HIT even though the origin sends no-cache.

Note on "safety floors": the floors that prevent caching when Set-Cookie / Authorization is present have one exception — if the origin also sends Cache-Control: public, these floors are skipped and the content is still cached. For this reason, do not let the origin return Cache-Control: public on responses that carry per-user data.

Other flags in a Cache Policy: Ignore query string, Disable auto compression, Edge/Browser TTL, Stale while revalidate / if error, a separate Cache Key/Vary, and Response headers (modify the response headers). Conditions support the fields: url_path, query_string, method, hostname, user_agent, cookie, origin, via, ip_source; operators: equals, regex, starts_with, ends_with, contains (with case-insensitive variants).

Order of evaluation​

  • Cache Policy › domain Cache Settings › system-wide configuration. Within Cache Policy, the lower the priority number, the higher the precedence; the first matching rule (lowest priority number) wins.
  • Multiple rules can share the same priority — in a tie, the rule listed first is chosen.
  • A rule with an empty condition matches every request — give it a high priority number (runs last) to use it as a "default" rule, so it does not swallow all other rules.
  • Several rules for the same path: the rule with the lower priority number wins.

Troubleshooting​

SymptomCommon causeFix
Always X-Cache: MISSThe origin sends no-cache/no-store/Set-Cookie; or the query string differs on every requestUse a Cache Policy with Ignore no-cache origin (on the correct public paths); or set Query strategy = none/exclude
Old content is not updatedTTL is too longLower the TTL, or Purge that path (see the Purge & Warm page)
Cached content is mixed up between usersA personal page was force-cached by mistakeRemove Ignore no-cache origin from that path; cache only public paths
Cannot save, error 422Invalid field value (for example Edge TTL > Max TTL)Correct it according to the table in Fields: Cache Settings and save again

FAQ​

  • Is the cache cleared automatically when I update content? VNIS does not know about it automatically; Purge the changed path, or set a short TTL.
  • How do I know whether a URL is a HIT or a MISS? Turn on Enable X-Cache in the Cache Policy, then check the X-Cache header with curl -I.
  • I set a TTL of 1 day but the origin says 5 minutes. Which one wins? By default VNIS honors the origin; to enforce your TTL, use a Cache Policy with Ignore no-cache origin/set an Edge TTL.
  • Is it a problem to Vary on many headers? Each header in Vary creates another cache variant → lower HIT ratio. Keep the Vary list to a minimum (at most 8).