Download the PHP package toflar/psr6-symfony-http-cache-store without Composer

On this page you can find all versions of the php package toflar/psr6-symfony-http-cache-store. 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 psr6-symfony-http-cache-store

PSR-6 compatible Symfony HttpCache Store

Supported branches

Introduction

Symfony's HttpCache store implementation is rather old and was developed when there were no separate components for locking and caching yet. Moreover, expired cache entries are never pruned and thus causes your cache directory to continue to grow forever until you delete it manually.

Along the way, I needed support for cache invalidation based on tags which was pretty easy to implement thanks to the Symfony Cache component.

This bundle thus provides an alternative StoreInterface implementation that…

Installation

Configuration

For the Symfony 4/Flex structure, you need to adjust your index.php like this:

That's it, that's all there is to do. The Psr6Store will automatically create the best caching and locking adapters available for your local filesystem.

If you want to go beyond this point, the Psr6Store can be configured by passing an array of $options in the constructor:

Generating Content Digests

By default, this cache implementation generates content digests. This means that the response meta data is stored separately from the response content. If multiple responses share the same content, it is stored in the cache only once. Compare the following illustrations to see the difference:

With generating content digests:

Without generating content digests:

Generating content digests optimizes the cache so it uses up less storage. Using them, however, also comes at the costs of requiring a second round trip to fetch the content digest from the cache during the lookup process.

Whether or not you want to use content digests depends on your PSR-6 cache back end. If lookups are fast and storage is rather limited (e.g. Redis), you might want to use content digests. If lookups are rather slow and storage is less of an issue (e.g. Filesystem), you might want to disable them.

You can control the behaviour using the generate_content_digests configuration option.

Caching BinaryFileResponse Instances

This cache implementation allows to cache BinaryFileResponse instances but the files are not actually copied to the cache directory. It will just try to fetch the original file and if that does not exist anymore, the store returns null, causing HttpCache to deal with it as a cache miss and continue normally. It is ideal for use cases such as caching /favicon.ico requests where you would like to prevent the application from being started and thus deliver the response from HttpCache.

Cache Tagging

Tag cache entries by adding a response header with the tags as a comma separated value. By default, that header is called Cache-Tags, this can be overwritten in cache_tags_header.

To invalidate tags, call the method Psr6Store::invalidateTags or use the PurgeTagsListener from the FOSHttpCache library to handle tag invalidation requests.

Pruning Expired Cache Items

By default, this store removes expired entries from the cache after every 500 cache write operations. Fetching data does not affect performance. You can change the automated pruning frequency with the prune_threshold configuration setting.

You can also manually trigger pruning by calling the prune() method on the cache. With this, you could for example implement a cron job that loads the store and prunes it at a configured interval, to prevent slowing down random requests that were cache misses because they have to wait for the pruning to happen. If you have set up a cron job, you should disable auto pruning by setting the threshold to 0.

WARNING

It is possible to configure other cache adapters or lock stores than the filesystem ones. Only do this if you are sure of what you are doing. In this pull request Fabien refused to add PSR-6 store support to the Symfony AppCache with the following arguments:

While the first and third point depend on what you do and need, be sure to respect the second point. If you use network enabled caches like Redis or Memcache, make sure that they are not shared with other systems to avoid code injection!

Credits

I would like to thank David for his invaluable feedback on this library while we were working on an integration for the awesome FOSHttpCache library.


All versions of psr6-symfony-http-cache-store with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
symfony/lock Version ^6.0 || ^7.0
symfony/cache Version ^6.0 || ^7.0
symfony/http-foundation Version ^6.0 || ^7.0
symfony/http-kernel Version ^6.0 || ^7.0
symfony/options-resolver Version ^6.0 || ^7.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 toflar/psr6-symfony-http-cache-store contains the following files

Loading the files please wait ....