Download the PHP package darkperis/dpadn-laravel without Composer
On this page you can find all versions of the php package darkperis/dpadn-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download darkperis/dpadn-laravel
More information about darkperis/dpadn-laravel
Files in darkperis/dpadn-laravel
Package dpadn-laravel
Short Description ADN Cache Implementation for Laravel
License GPL-3.0-only
Informations about the package dpadn-laravel
Laravel ADNCache
This package allows you to use ADNcache together with Laravel.
It provides one facade:
- ADNCache facade to handle purging
Installation
Require this package using composer.
Laravel uses Auto-Discovery, so you won't have to make any changes to your application, the two middlewares and facade will be available right from the beginning.
Steps for Laravel >=5.1 and <=5.4
The package can be used for Laravel 5.1 to 5.4 as well, however due to lack of Auto-Discovery, a few additional steps have to be performed.
In config/app.php you have to add the following code in your aliases:
Copy adncache.php to config/:
Copy the package config/adncache.php file to your config/ directory.
important: Do not add the ServiceProvider under providers in config/app.php.
Steps for Laravel 5.5 and above
You should publish the package configuration, which allows you to set the defaults for the Cache-Control header:
Usage
The package comes with 2 functionalities: Setting the cache control headers for adncache and purging.
cache-control
You'll be able to configure defaults in the config/adncache.php file, here you can set the max-age (default_ttl), the cacheability (default_cacheability) such as public, private or no-cache or enable esi (esi) in the Cache-Control response header.
If the default_ttl is set to 0, then we won't return the Cache-Control response header.
You can control the config settings in your .env file as such:
ADNCACHE_API_KEY- Specify the API Token for your Service at the Edgeport PlatformADNCACHE_ENDPOINT- accepts endpointADNCACHE_ESI_ENABLED- acceptstrueorfalseto whether you want ESI enabled or not globally; DefaultfalseADNCACHE_DEFAULT_TTL- accepts an integer, this value is in seconds; Default:0ADNCACHE_DEFAULT_CACHEABILITY- accepts a string, you can use values such asprivate,no-cache,publicorno-vary; Default:no-cacheADNCACHE_GUEST_ONLY- acceptstrueorfalseto decide if the cache should be enabled for guests only; Defaults tofalse
You set the cache-control header for adncache using a middleware, so we can in our routes do something like this:
purge
If we have an admin interface that controls for example a blog, when you publish a new article, you might want to purge the frontpage of the blog so the article appears in the overview.
You'd do this in your controller by doing
You can also purge everything by doing:
One or multiple URIs can be purged by using a comma-separated list:
`
Laravel Authentication
If you use authentication in Laravel for handling guests and logged-in users, you'll likely want to also separate the cache for people based on this.
This can be done in the .htaccess file simply by using the cache-vary on the Authorization cookie:
Note: In the above example we use Authorization, this may have a different name depending on your setup, so it has to be changed accordingly.
All versions of dpadn-laravel with dependencies
guzzlehttp/guzzle Version ^7.0.1