Download the PHP package joostvanveen/laravel-litespeedcache without Composer

On this page you can find all versions of the php package joostvanveen/laravel-litespeedcache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-litespeedcache

coverage

joostvanveen/laravel-litespeedcache

A Laravel wrapper for joostvanveen/litespeedcache. If you wish to use Litespeed Cache outside of Laravel check out this framework agnostic https://github.com/joostvanveen/litespeedcache

Installation

Require the package using composer:

Enable the Litespeed in your .htaccess file.

Usage

This package adds a LitespeedCache cache facade for easy use and sets middleware that automatically caches all requests, according to the config settings.

You can set which URLs (for instance any adminconsole*) and query strings not to cache in config. If you want to preview a page without cache, simply add ?cache_bypass=1 to a URL, or set a cache_bypass cookie with a vale of 1.

If you want to set your own middleware, you can set the package to not use the default middleware.

Configuration

To be able to adjust the configuration for this package, publish the configuration files to your project's /config folder like so:

The config file adds the following settings to your Laravel configuration:

Facade

The package registers \Joostvanveen\Litespeedcache\Cache as a facade and sets default config values for litespeedcache.defaults.enabled, litespeedcache.defaults.type, litespeedcache.defaults.lifetime, litespeedcache.defaults.excludedUris, and litespeedcache.defaults.excludedQueryStrings.

You can use all methods from \Joostvanveen\Litespeedcache\Cache, see https://github.com/joostvanveen/litespeedcache/blob/master/README.md for full documentation.

Some examples:

Middleware

By default, the package contains a middleware that caches all pages (except cli).

You can find this middleware at src/Middlewares/Cache.php.

If you want to use your own middleware, you can disable the default middleware by setting the config value litespeedcache.defaults.use_middleware to false

  1. Publish the config settings to your Laravel project.

  2. Set use_middleware to false

  3. Create a middleware class

  4. Edit your middleware

Cache and csrf tokens in form requests

Laravel has built in security to guard against csrf attacks, using a csrf token. A token check is done on every POST request.

Typically, you provide the csrf token as a hidden field in a form, using csrf_field() or in a POST ajax request, using something like $.post(route('my.route'), $('#form').serialize() + "&_token={{ csrf_token() }});

This poses a problem when used with a full page cache like Litespeed Cache or Varnish. The csrf is unique and should not be stored in cache. If it is you will be posting a cached csrf token instead of a fresh one, resulting in a 'This page has expired' error on doing a POST request. However, you do want to store the rest of the page in cache. You need some way to do hole punching in your cached page. ESI to the rescue.

This package provides two ways to use csrf tokens in you pages as an ESI block. On constructing the cached page, the ESI block will be replaced by the actual, uncached csrf token. This way you can have a fully cached paged, but with a uncached token.

Use the following code to include a hidden field in a form on a cached page, instead of csrf_field(). The 'litespeedcache.routes.field' route is part of this package an will return a hidden field with csrf token.

ESI helper functions

This package comes with an easy helper functions to display an ESI block in your form.

This will display the proper ESI block if ESI is enabled, and a regular crsf_field() if ESI is not enabled.

Sometimes you need just the token, for instance for ajax POST requests. That's why there is also a special helper function that returns just the token.

This will display the proper ESI block if ESI is enabled, and a regular crsf_token() if ESI is not enabled.

Of course, you are free to manually code the ESI blocks into your forms as well.

ESI not supported by your server?

Not all Litespeed servers support ESI. If you are on a Litespeed server that does not support ESI, you can insert an uncached token into your form using ajax, since ajax requests are never cached by joostvanveen/litespeecache.

joostvanveen/litespeedcache documentation

You can find the Litespeed Cache documentation here https://github.com/joostvanveen/litespeedcache/blob/master/README.md

Litespeed documentation

You can find the Litespeed Cache documentation here https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:developer_guide:response_headers

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Changelog

Changelog

License

MIT


All versions of laravel-litespeedcache with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
joostvanveen/litespeedcache Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package joostvanveen/laravel-litespeedcache contains the following files

Loading the files please wait ....