Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/azonmedia/component-request-caching
Caching component for GuzabaPlatform
https://github.com/azonmedia/component-request-caching
Last synced: about 2 months ago
JSON representation
Caching component for GuzabaPlatform
- Host: GitHub
- URL: https://github.com/azonmedia/component-request-caching
- Owner: AzonMedia
- License: mit
- Created: 2019-11-25T14:22:59.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-07T14:49:11.000Z (almost 4 years ago)
- Last Synced: 2024-05-02T14:13:44.794Z (8 months ago)
- Language: PHP
- Size: 30.3 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GuzabaPlatform\RequestCaching
Request Caching component for [GuzabaPlatform](https://github.com/AzonMedia/guzaba-platform).
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).