Problem/Motivation

The Viewer submodule's response cache hardcodes the three core download routes in EpubResponseCacheSubscriber::CACHED_ROUTES. Modules that add their own download routes on top of the generator (e.g. epub_generator_localgov_publications) cannot opt in, so their downloads are regenerated on every request. Route extensibility alone is insufficient: a third-party route also needs to enrich the invalidation tags (e.g. an outline-level tag when the route parameter is not the outline root), or its cached entries go stale.

Proposed resolution

Add two alter hooks: hook_epub_generator_viewer_cached_routes_alter(array &$routes) to extend the cached route list, and hook_epub_generator_viewer_cache_tags_alter(array &$tags, array $context) to adjust invalidation tags per entry, with the request and resolved source entity in $context. Document both in a new epub_generator_viewer.api.php, including the requirement that added routes use a {node} or {entity_type}/{entity_id} parameter so the subscriber can resolve the source (unresolvable sources are never cached, by design).

Remaining tasks

Review; kernel test covering an altered-in route (hit, miss, and tag invalidation). epub_generator_localgov_publications adopts the hooks once released.

User interface changes

None.

API changes

Two new alter hooks; EpubResponseCacheSubscriber gains a module_handler constructor argument (internal service, no BC concern).

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

andileco created an issue. See original summary.

  • andileco committed f5f927ba on 1.0.x
    task: #3612025 Make the response cache's route list and cache tags...
andileco’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.