feat(page-cache): full-page HTTP cache with file driver, tag invalidation, and entity bridge#58
Open
michalbiarda wants to merge 4 commits into
Open
Conversation
…ages Introduces full-page HTTP response caching with attribute-driven opt-in, tag-based invalidation, and a global middleware that intercepts requests to serve or store cached responses. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Move helper functions from Pest.php into helpers.php (package-scoped require_once) so they load correctly under the root phpunit.xml runner - Rename createDriver/cleanupDir to createPageCacheFileDriver/cleanupPageCacheDir to avoid global function collisions with cache-redis and database tests - Rename makeRequest/makeResponse to makeCacheCheckerRequest/makeCacheCheckerResponse in CacheabilityCheckerTest to avoid collision with layout package tests - Fix PackageStructureTest dirname depth (2→3) for root composer.json lookup - Add missing .gitattributes, LICENSE to page-cache and page-cache-file packages - Add page-cache and page-cache-file to GitHub issue templates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…event public/ exposure FilePageCacheDriver now injects ProjectPaths and resolves relative paths against the project base directory, matching the DebugbarStorage pattern. This prevents cache files from landing in public/ when PHP's CWD is set to the web root. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…age-cache-entity bridge - CacheTagProviderInterface + provider param on #[Cacheable] for per-request dynamic tags - IdentityInterface in marko/page-cache for entities to declare their cache identities - PageCacheMiddleware resolves provider via container, merges static + dynamic tags (deduplicated) - marko/page-cache-entity bridge package: IdentityPurger + three observers (Created/Updated/Deleted) - IdentityBridgeValidator: loud-fail boot check when IdentityInterface is used without the bridge installed - README and docs updates for all new extension points Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
@markshust The whole feature was implemented using your Claude Code automation. When you decide to merge it, I'll work on implementing more drivers (Varnish, etc.). File driver was a proof of concept. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces three new packages for full-page HTTP response caching:
marko/page-cache— interface package withPageCacheInterface,#[Cacheable(ttl, tags, provider)]attribute,PageCacheMiddleware(registered globally),CacheabilityChecker, CLI commands (page-cache:clear,page-cache:purge,page-cache:status),CacheTagProviderInterfacefor dynamic per-request tags,IdentityInterfacefor entity-driven invalidation, and a boot-timeIdentityBridgeValidatorthat fails loudly when the bridge is missingmarko/page-cache-file— file driver implementingPageCacheInterfacewith atomic writes and tag reverse-index forpurgeTag()marko/page-cache-entity— bridge package: three auto-discovered observers (PurgeOnEntityCreated/Updated/Deleted) delegate toIdentityPurger, which purges all tags returned by entities implementingIdentityInterfacewhen saved or deletedTest plan
composer testpasses./vendor/bin/phpcs && ./vendor/bin/php-cs-fixer fixpasses with no changes#[Cacheable]are served from cache on second requestpage-cache:purge <url>andpage-cache:purge --tag <tag>clear the correct entries#[Cacheable(provider: SomeProvider::class)]merges dynamic tags with static tagsIdentityInterfacepurges its tags from the page cachePageCacheException::missingEntityBridge()whenIdentityInterfaceis implemented without the bridge installed🤖 Generated with Claude Code