Back to the Proxy Cache section
HyperCache Dedup (cache deduplication) makes the proxy store one copy of an object that the Internet serves under many different addresses: Windows updates, Linux packages, game downloads, images and videos spread over CDN servers. Users get it from the local cache instead of downloading it again from the Internet.
Websites that serve many images or large files use a CDN (Content Delivery Network): the downloads are spread over many servers and countries. Microsoft, Apple, Google, Steam and Linux distributions work this way.
A proxy stores each object under its address (its URL). With a CDN, the same file is reachable through many addresses, for example:
http://cdn1.images.domain.tld/picture.pnghttp://cdn2.images.domain.tld/picture.pnghttp://cdn3.images.domain.tld/picture.pnghttp://cdn4.images.domain.tld/picture.png
Without HyperCache, the proxy sees four different objects: it downloads and stores the same picture four times, and a user sent to cdn3 gets nothing from the copy fetched through cdn1.
For each request, the proxy asks HyperCache under which name (the cache key) the object must be stored. HyperCache answers with the same internal key for all the addresses of the same object:
http://cdn1.images.domain.tld/picture.png => http://images.SQUIDINTERNAL/picture.pnghttp://cdn2.images.domain.tld/picture.png => http://images.SQUIDINTERNAL/picture.pnghttp://cdn3.images.domain.tld/picture.png => http://images.SQUIDINTERNAL/picture.pnghttp://cdn4.images.domain.tld/picture.png => http://images.SQUIDINTERNAL/picture.png
Keys always end in .SQUIDINTERNAL: they are names, never addresses the proxy connects to. The download itself still goes to the real server; only the storage and the lookup in the cache use the key. When HyperCache does not know an address, it leaves it unchanged and the proxy behaves as usual.
storeid_file_rewrite, that the proxy starts as a helper (Squid store_id_program). Up to 20 copies run in parallel, 5 of them started in advance.wpad.dat / proxy.pac, Microsoft connectivity checks, webmails, ads servers, Artica's own servers;http://other-site.example/x.microsoft.com/a.js never receives Microsoft's key, so another website cannot place its own file in the cache under Microsoft's name.If the HyperCache helpers die faster than the proxy can restart them (the proxy logs "Too few store_id processes"), the Artica daemon switches HyperCache to emergency mode: the proxy is restarted without HyperCache and keeps serving users normally, without deduplication. The top bar of the console then shows "The HyperCache is in Emergency mode". See Managing HyperCache below to leave it.
Artica updates ship new versions of the helper. Every 5 minutes, the Artica daemon checks whether a newer helper was delivered, installs it and, when HyperCache is running, reloads the proxy so that the helpers restart on the new version. No action is needed: allow up to 5 minutes after an update.
windowsupdate.com, download.microsoft.com, Delivery Network shards). Each update is downloaded from the Internet once per site instead of once per mirror. This is the main gain on networks of tens to thousands of Windows computers.debian/…, debian-security/…) are deduplicated whichever Debian mirror the machines use.HyperCache only works when the proxy stores objects on disk. It is inactive, and its configuration file /etc/squid3/StoreID.conf only contains a comment giving the reason, in these cases (checked in this order):
| Comment in StoreID.conf | Reason |
|---|---|
DISABLED | the feature is disabled |
Enable Intel Celeron | the Intel Celeron (low resources) mode is enabled |
SquidCacheLevel == 0 | the proxy has no disk cache |
SquidDisableCaching == 1 | caching is temporarily disabled |
Emergency mode! | the whole proxy is in emergency mode |
Temporary disabled | deduplication is paused |
StoreID Emergency mode | HyperCache is in emergency mode |
Not a 3.5 or 4.x and later version | the Squid version is too old |
Update binary failed | the helper could not be installed |
Caching > Status. The HyperCache Dedup tile shows the status of the service.
Pausing stops the deduplication without disabling the feature (for example while investigating a caching problem). In the proxy Actions window, the HyperCache button pauses the deduplication ("Disable Hypercache") or resumes it ("Enable HyperCache"). The configuration is rebuilt, checked by the proxy and applied; if the proxy rejects it, the previous configuration is kept. Objects already in the cache stay there.
The Artica AI assistant knows HyperCache. Ask it in plain language, for example "Is HyperCache working?", "Why is HyperCache inactive?", "Which deduplication rules are ignored?". It reads the real state from the appliance: active or not and why, helper version and pending update, running helpers, emergency mode and when leaving it will be allowed, rules loaded and ignored.
It can also act, always through verified transactions that can be rolled back:
| Action | Approval |
|---|---|
| Apply the configuration (rebuild, check by the proxy, reload only when something changed) | can run on its own (Autopilot, runbooks, agent) |
| Leave the emergency mode: refused while no up-to-date helper is installed and during the 30 minutes after the emergency started; checked again 60 seconds later | approval, or on its own only for the agent investigating an incident, once |
| Enable, disable, pause or resume HyperCache | always approved by an administrator |
| Add, change, enable, disable, move or remove a deduplication rule | always approved by an administrator |
Each change is proven by reading the state back (helpers running, rule loaded by the helper). If the proof fails, the previous state is restored and read back. Changes are refused on an Artica cluster slave (its settings and rules are replaced by the master's: make them on the master) and on a HaCluster load-balancer.
A rule is a pair: a pattern (a regular expression that recognizes the addresses) and a key (the common name, with $1, $2… for the parts captured by the pattern). Artica ships default rules; administrator rules are managed through the Artica AI assistant. Example, for an editor whose files come from many download servers:
Pattern: ^https?://[^/?#]*\.example\.net/(.*)
Key: http://example-downloads.SQUIDINTERNAL/$1
With this rule, http://dl1.example.net/setup/v2.exe and http://dl7.example.net/setup/v2.exe share the key http://example-downloads.SQUIDINTERNAL/setup/v2.exe.
To protect the cache, a rule is refused before anything is changed when:
^https?:// followed by the host name, closed by /, ?, # or the end of the address. A pattern such as .*\.example\.com/ or ^https?://[^/]*\.example\.com/ would also match http://attacker.example/x.example.com/, and that website could replace the files of example.com in the cache. Use [^/?#]*\. for "any sub-domain";a|b): group the alternatives, (?:a|b);http://<name>.SQUIDINTERNAL/, or uses $1… in its host name;$2) that the pattern does not capture, or the pattern does not compile;Good practices: keep the query string in the key unless it is only a signature; on shared CDNs keep the host name in the key; put specific rules before generic ones (a new rule is placed first). An Artica default rule cannot be deleted, because it would come back at the next rebuild: disable it instead. Changing a default rule creates an administrator rule at its place and disables the default.
/lib/squid3/storeid_file_rewrite -version (2.0.0 or later)./var/log/squid/storeid.log, one JSON line per event. The starting line gives the total number of rules the helper evaluates (its built-in rules included); invalid file rule ignored lines name the table rules it ignored. Set the STOREID_DEBUG token to 1 to log every address and its key.(storeid_file_rewrite) processes, children of the proxy./var/log/squid/cache.log shows "Processing Configuration File: /etc/squid3/StoreID.conf" and "Starting N/M 'storeid_file_rewrite' processes".