guzaba-platform / request-caching
GuzabaPlatform Request Caching component
Installs: 18
Dependents: 0
Suggesters: 2
Security: 0
Stars: 0
Watchers: 5
Forks: 0
Open Issues: 1
Type:guzaba-platform-component
Requires
- composer/composer: ^1.3
- guzaba-platform/components-base: dev-master
- guzaba-platform/guzaba-platform: dev-master
- guzaba-platform/guzaba-platform-installer: dev-master
Requires (Dev)
- composer/composer: ^1.3
This package is auto-updated.
Last update: 2024-12-07 22:48:26 UTC
README
Request Caching component for GuzabaPlatform.
Caches the request responses if the used ActiveRecord objects in the request were not modified (or no new ones were created from the same classes).
Installation and configuration
$ composer require guzaba-platform/request-caching
No configuration is required. After installation on application startup the following message should be displayed:
[2.022402 Startup] Installed components:
...
- guzaba-platform/request-caching - GuzabaPlatform\RequestCaching : /home/local/PROJECTS/guzaba-platform-marketplace/guzaba-platform-marketplace/vendor/guzaba-platform/request-caching/app/src
...
And if initialized successfully:
[2.022484 Startup] Middlewares:
...
- GuzabaPlatform\RequestCaching\CachingMiddleware - guzaba.source:///home/local/PROJECTS/guzaba-platform-marketplace/guzaba-platform-marketplace/vendor/guzaba-platform/request-caching/app/src/CachingMiddleware.php
...
Preventing requests from beign cached
There are two ways to prevent a request to be cached:
- the $Request to contain an attributed "no_cache"
- the $Response to contain a header "pragma: no-cache" or "cache-control: no-cache"
Additional details
It injects a new middleware - GuzabaPlatform\RequestCaching\CachingMiddleware and registeres a callback on ActiveRecord:_after_read event. It also uses the OrmMetaStore service to obtain the last modification times of the objects (and creation of new ones using the class meta data).