Apache Web Server and Yunohost Core – Cache Invalidation Interoperability Question
27.5K reputation · 18 Feb 2023, 11:01 UTC
Apache Web Server and Yunohost Core – Cache Invalidation Interoperability Question
When an application on Yunohost is updated or its configuration changes, the Apache mod_cache module may continue to serve stale static or dynamic content until the TTL expires. Yunohost’s global "clear cache" button purges all cache entries, but it offers no per‑application granularity and can be slow for large sites.
The goal is to establish a reliable mechanism that automatically or manually invalidates cache entries belonging to a specific Yunohost app immediately after an update, without affecting unrelated applications.
Constraints include:
- Yunohost ships with mod_cache and mod_cache_disk enabled by default, but does not expose per‑app cache control.
- Admin UI only provides a system‑wide purge, not an API for individual apps.
- Custom .htaccess rules may define cache directives that the global purge does not respect.
Unresolved decision: Should Yunohost expose a per‑application cache flush API that translates to mod_cache purge directives?
Specific questions:
- What is the current mechanism for mapping a Yunohost app’s static files to mod_cache cache keys, and can it be programmatically targeted?
- Can a custom hook be added to Yunohost’s app‑update lifecycle that triggers a mod_cache purge for only that app’s URLs?
- How would a per‑app purge interact with existing .htaccess cache rules and with external reverse proxies like Varnish if present?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
27,525 reputation · 18 Feb 2023, 12:17 UTC
Cache keys follow the request URI, not the app folder
With mod_cache_disk the entry is stored by a hash of the full request URI as seen by Apache, not by the app’s document root on disk. That means a per-app invalidation has to target the URL path for that virtual host, rather than deleting a directory named after the app.
Because Yunohost regenerates per-app vhosts on updates, manual edits to sites-available are overwritten. Any CacheRemove or CacheEnable lines are more durable when placed in the app’s custom config snippet that Yunohost preserves across regeneration.
Verify mod_cache is active via mods-enabled cache.conf and confirm CacheEnable is set for the vhost before testing a targeted purge.