Download the PHP package bakame/http-cache-status without Composer

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

Cache-Status HTTP Header Field

This package contains classes used to parse, validate and manipulate the Cache-Status HTTP Response Header Field.

System Requirements

PHP >= 8.2 is required but the latest stable version of PHP is recommended.

Usage

Unless explicitly stated, all the classes described hereafter are immutable.

Parsing

The package can parse the Header from ab HTTP Request or Response using the Field class as follows:

Field Container

The Field class is a container whose members are handled request cache information as they are added by the various servers. The class implements PHP's IteratorAggregate, ArrayAccess, Countable and Stringable interface.

You can also determine if a specific handled cache request exist either by supplying the cache index or its server identifier

As per the RFC the closestToOrigin and closestToUser methods give you access to the caches closest to the origin server and the one closest to the client (user).

Both methods return null if no HandledRequestCache instance is found.

The Handled Request Cache object

A HandledRequestCache instance contains information about the cache and how it was handled for the current message. In particular, in compliance with the RFC, if the forward property is present you will get extra information regarding the reason why the cache was forwarded. From the POV of the cache the only required check needed is the following:

The class lists all the available reason via the ForwardedReason Enum.

You can push more HandledRequestCache instances to the Field container using the push method. The method supports pushing HandledRequestCache instances as well as HTTP text representation of the handled request cache.

Serializing the message field

Once you have created or updated you Field instance you just need to add it to your response header using the toHttpValue method or the __toString() to generate the correct HTTP text representation to insert in your message header.

While we used PSR-7 ResponseInterface, The package parsing and serializing methods can use any HTTP abstraction package or PHP $_SERVER array.

In this last example we use PHP native function to parse and add the correct header to the PHP emitted HTTP response.

Structured Fields

Because the Header field is compliant with the HTTP Structured Field RFC. We can easily parse it but were are also validating it against its specific RFC rules. To do so the package is dependent on the HTTP Structured Fields for PHP v2.0 package, which remove all the boilerplate needed for such header to be parsed, validated and manipulated in PHP while staying compliant with all the different RFCs.


All versions of http-cache-status with dependencies

PHP Build Version
Package Version
Requires bakame/http-structured-fields Version ^2.0
php Version ^8.2
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 bakame/http-cache-status contains the following files

Loading the files please wait ...