See also the GitHub releases page.
- Add events
PRE_FORWARD
andPOST_FORWARD
to allow event listeners to alter the request before and after it is sent to the backend. - Changed CustomTtlListener to use the
POST_FORWARD
event instead ofPRE_STORE
. UsingPRE_STORE
, requests that are not considered cacheable by Symfony were never cached, even when they had a custom TTL header. - Add flag
fallbackToSmaxage
toCustomTtlListener
to allow controlling fallback tos-maxage
if custom TTL header is not defined on the response. - Fix: Do not call store if Response object is not longer cacheable after event
listeners. If you use the custom TTL system, this is only a performance
improvement, because the TTL of the response would still be 0. With a custom
listener that changes the response explicitly to not be cached but does not
change
s-maxage
, this bug might have led to caching responses that should not have been cached.
- Support Symfony 7
- Drop support for Symfony < 6.4
- Test with PHP 8.2 and 8.3
- Drop support for PHP < 8.1
- Switched to PSR-17 message factories
- Switched some places to PSR-18 HTTP client. The main functionality needs the Httplug Async Client specification. There is no PSR for asynchronous clients.
- Parameter and return type declarations where possible.
- Ignore empty tag lists passed to
TagCapable::invalidateTags
so you don't need to check if there are tags or not.
- The new
EventDispatchingHttpCache::forward
method added in 2.16.0 was not compatible with Symfony 4.4. Adjusted the signature to make it compatible.
(Mistaken tag, same as 2.16.0)
- Add events
PRE_FORWARD
andPOST_FORWARD
to allow event listeners to alter the request before and after it is sent to the backend. - Changed CustomTtlListener to use the
POST_FORWARD
event instead ofPRE_STORE
. UsingPRE_STORE
, requests that are not considered cacheable by Symfony were never cached, even when they had a custom TTL header. - Add flag
fallbackToSmaxage
toCustomTtlListener
to allow controlling fallback tos-maxage
if custom TTL header is not defined on the response. - Fix: Do not call store if Response object is not longer cacheable after event
listeners. If you use the custom TTL system, this is only a performance
improvement, because the TTL of the response would still be 0. With a custom
listener that changes the response explicitly to not be cached but does not
change
s-maxage
, this bug might have led to caching responses that should not have been cached.
- Avoid deprecated
RequestMatcher
in favor ofIpsRequestMatcher
.
- Declare incompatibility with Symfony 7 because it removes
RequestMatcher
.
- Directly require
php-http/message-factory
to keep working with the legacy factories.
- Provide a
TagHeaderParser
that can split up a tag header into the list of tags. This allows to correctly handle non-default tag separators in all places.
- Fixed varnish configuration examples to say
Authorization
and notAutorization
.
- Fixed dummy interface name for code scanners to match the expected name.
- Removed the internal BaseEvent class and extend our events from the Symfony contracts class directly.
- Made the CacheInvalidation interface compatible with Symfony 6.
Symfony 6 does a BC break for
HttpKernelInterface::fetch
- if you implement the method in your application, you need to adjust when upgrading to Symfony 6.
- Allow installation with Symfony 6 components
- Drop support for Symfony 3, minimal version is now 4.3
- Do not extend the wrong Event class when installed with legacy Symfony but the Symfony contracts happen to be installed
- Added Cloudflare ProxyClient Adapter with ClearCapable, PurgeCapable and TagCapable. This allows to use FOSHttpCache to invalidate caches on Cloudflare. See the "Proxy Client" section of the documentation for how to configure the Cloudflare client.
- Added a
fos_user_context_hash
method to be called invcl_hash
when using the user context hash mechanism. This can avoid performance problems Varnish can run into when the hashVary
s on the basic authentication or session cookie. If you use the user context, read the updated documentation and callfos_user_context_hash
in yourvcl_hash
function.
- Implemented ClearCapable.
- Added flag on CustomTtlListener to allow keeping the custom TTL header on the response
- Marked the
@internal
constants inFOS\HttpCache\ProxyClient\Fastly
as private
- Fix how we create exceptions to get the expected exception rather than a PHP error
- Raised minimal PHP version to 7.2
- Added support for PHP 8.0
- Added a neutral "Bad Request" body to user hash mismatch response to have something searchable in the code when debugging.
- Fix: Preserve inline credentials when multiplexing to the proxy servers.
- Allow to use inline credentials for the caching proxy URL in the format http://user:[email protected]
- Raised minimal PHP version to 7.1
- Test helper classes upgraded to support PHPUnit 7/8
- There is no php-http/discovery package 2.0, drop it from composer.json
- Adapt for changes to NetworkException in HTTPlug 2.1 for PSR-18 compatibility
- Fixed issue with
PurgeTagsListener
and Symfony 5 - Fixed clearing the cache completely together with toflar psr6 store did not work
- Support Symfony 5
- Use
LegacyEventDispatcherProxy
for Symfony >= 4.3 to avoid deprecation messages. - Added Fastly ProxyClient Adapter with ClearCapable, PurgeCapable, RefreshCapable, & TagCapable. Fastly is a CDN originally based on Varnish 2.x, so with many of the same capabilities like VCL and more.
- Added request type to the CacheEvent.
- Added: ClearCapable to clear the whole cache in one efficient call. Currently supported only by the Symfony HttpCache.
- Allow installing with Httplug 2.0 / PSR-18.
- Fixed: Avoid regression of 2.5.3: If there are no messages to be dispatched, do not throw an exception if the HttpCache is not set.
- Fixed: Handle HttpCache not available in KernelDispatcher and fix return type annotations - if HttpCache is not set, it can't be returned.
- Fixed: Remove the xkey header in vcl_deliver if we are not in debug mode
- Do not cleanup the Vary header and keep the user context hash if we are in debug mode
- Fixed: Clear the ResponseTagger after we tagged a response. Usually PHP uses a new instance for every request. But for example the hash lookup when using Symfony HttpCache does two requests in the same PHP process.
- Fixed:
MaxHeaderValueLengthFormatter::getTagsHeaderName
now actually returns the value.
- Added:
MaxHeaderValueLengthFormatter
to allow splitting cache tag headers into multiple headers.
- Have cache invalidator check for presence of Psr6Store for a better guess whether the cache really is TagCapable or not.
- Added:
CleanupCacheTagsListener
to remove the cache tags header from the final response that is sent to the client. Add this listener to your cache kernel.
- Improved: The
ResponseTagger
does now remove duplicate tags.
- Fixed: Do not
preg_quote
tags when using xkey. Quoting is only used for BAN requests that expect a regular expression. This bug only affected you if you use xkey and used characters in your tags that are changed bypreg_quote
.
- The
HttpProxyClient
now accepts an instance of the newDispatcher
interface instead of the concreteHttpDispatcher
, allowing for more flexibility.
- Introduced a new
KernelDispatcher
for the Symfony proxy that calls the application kernel directly instead of executing a full HTTP request.
- The provided VCL for custom TTL no longer provides
import std;
because each import may only exist once.
- Added support for the more efficient xkey cache tag system. BAN remains the default cache tagging system, but if you can install the varnish modules in your system, it is recommended to update to xkey.
- No inline C is needed for the custom TTL header with Varnish 4 or better. use
std.duration()
instead.
- You can now also specify which headers are used for
authentication to detect anonymous requests. By default, the headers are the
previously hardcoded
Authorization
,HTTP_AUTHORIZATION
andPHP_AUTH_USER
.
- Fixed bug in Symfony tag invalidation. Do not check if host is missing in request creation.
- Fixed issue with detection if toflar psr6 store is available.
-
Updated X-Cache-Tags regex to prevent matching partial tags
Invalidating objects with a tag of 'bar' would have previously also have invalidated objects with a tag that ends in 'bar', eg. 'foobar'. Now when invalidating an object the tag name must match in full.
- Support Symfony 4.
- Upgraded phpunit to 5.7 / 6. If you use anything from the
FOS\HttpCache\Test
namespace you need to update your project to use PHPUnit 6 (or 5.7, if you are using PHP 5.6).
-
Cache tagging support for Symfony HttpCache
Added a
PurgeTagsListener
for tag based invalidation with the SymfonyHttpCache
reverse caching proxy. This requires the newly created Toflar Psr6Store built on PSR-6 cache and supporting pruning expired cache entries. -
Using Request::isMethodCacheable rather than Request::isMethodSafe to correctly handle OPTIONS and TRACE requests.
-
Support PHP 7.2
Avoid warning about
count(null)
in PHP 7.2.
- Ban requests now work even when no base URI is configured.
- Raised minimum PHP version to 5.6.
- BC break: Removed the
Interface
suffix from all interfaces. - BC break: Renamed
HashGenerator
toDefaultHashGenerator
. - Added
HashGenerator
interface.
- BC break: Replaced hard coupling on Guzzle HTTP client with HTTPlug. You now need to explicitly specify a supported HTTP adapter in composer.json; see installation instructions.
- BC break: Separated the HttpDispatcher from the proxy clients. All existing clients still use HTTP to send invalidation requests.
- Added support and documentation for setting a custom TTL specifically for the caching proxy.
- BC break: Renamed the log event listener from
LogSubscriber
toLogListener
.
- BC break: Renamed the
Ban
,Purge
,Refresh
andTag
interfaces toBanCapable
,PurgeCapable
,RefreshCapable
andTagCapable
.
- BC break: Moved tag invalidation to
CacheInvalidator
, and renamedTagHandler
toResponseTagger
. - Abstracting tags by adding new
TagCapable
for ProxyClients. - Added
strict
option toResponseTagger
that throws an exception when empty tags are added. By default, empty tags are ignored. - Added
TagHeaderFormatter
interface that is used within theResponseTagger
to provide the header name and for formatting the tags header value.
- Varnish configuration are now files that you can directly include from your .vcl and call custom functions to avoid copy-pasting VCL code.
- Added support for and changed default to Varnish version 5.
- Moved Varnish 4 and 5 configuration files from
resources/config/varnish-4/
toresources/config/varnish/
. - Changed default Varnish version to 5.
- Removed special case for anonymous users in user context behaviour. Varnish now does a hash lookup for anonymous users as well.
- The NGINX purge location is no longer passed as constructor argument but by
calling
setPurgeLocation()
.
- BC break: Renamed all event listeners to
XxListener
instead ofXxSubscriber
. - BC break: Constructors for
PurgeListener
andRefreshListener
now use an options array for customization. - BC break: Converted abstract event dispatching kernel class
EventDispatchingHttpCache
to a trait, which now provides theaddSubscriber
andaddListener
methods. In yourAppCache
, replaceAppCache extends EventDispatchingHttpInterface
with ause EventDispatchingHttpCache;
statement. - The user context by default does not use a hardcoded hash for anonymous users but does a hash lookup. You can still configure a hardcoded hash.
- BC break: Refactored the proxy client test system into traits. Removed
ProxyTestCase
; use the traitsCacheAssertions
andHttpCaller
instead. - Added HTTP method parameter to
HttpCaller::getResponse()
.
- BC break: The
ResponseTagger
no longer expects an instance ofTagCapable
as first argument. To adjust the tag header name or the way the tags are formatted, use the newheader_formatter
option with aTagHeaderFormatter
.
- [Symfony HttpCache] Added a neutral "Bad Request" body to user hash mismatch response to have something searchable in the code when debugging.
- Symfony user context: You can now also specify which headers are used for
authentication to detect anonymous requests. By default, the headers are the
previously hardcoded
Authorization
,HTTP_AUTHORIZATION
andPHP_AUTH_USER
.
- Avoid problem with http_method_override.
- Avoid warning about
count(null)
in PHP 7.2.
- The TagHandler constructor now accepts a
headerLength
argument which will cause itsinvalidateTags
function to invalidate in batches if the header length exceeds this value.
- Support for Symfony 3.
- Added symfony/http-kernel HttpCache client.
- Added SymfonyTestCase.
- Removed unneeded files from dist packages.
- Added
TagHandler->hasTags()
method.
- Added authentication support to user context subscribe.
- Fixed usage of deprecated Guzzle subtree splits.
- Fixed exposed cache tags.
- Added TagHandler.
- It is no longer possible to change the event dispatcher of the CacheInvalidator once its instantiated. If you need a custom dispatcher, set it right after creating the invalidator instance.
- Deprecated
CacheInvalidator::addSubscriber
in favor of either using the event dispatcher instance you inject or doinggetEventDispatcher()->addSubscriber($subscriber)
.
- Added support for the symfony/http-kernel component reverse proxy HttpCache.
- Fixed documentation for user context varnish configuration to also work when
client omits the
Accept
HTTP header.