Skip to content

Update section about http cache #16402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2022
Merged

Conversation

nicolas-grekas
Copy link
Member

Fix #13881

@javiereguiluz javiereguiluz changed the base branch from 5.3 to 5.4 February 9, 2022 16:33
@javiereguiluz javiereguiluz merged commit c314c7d into symfony:5.4 Feb 9, 2022
@javiereguiluz
Copy link
Member

Nicolas, thanks a lot for providing these missing docs!

OskarStark added a commit that referenced this pull request Mar 2, 2023
…s (HypeMC)

This PR was merged into the 5.4 branch.

Discussion
----------

[HttpCache] Explain how to extend the `HttpCache` class

Followup to #16402.

In versions of Symfony prior to 5.4 the caching kernel was enabled by wrapping the default kernel into it inside the front controller, eg:

```php
// public/index.php
use App\CacheKernel;
use App\Kernel;

// ...
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
// Wrap the default Kernel with the CacheKernel one in 'prod' environment
if ('prod' === $kernel->getEnvironment()) {
    $kernel = new CacheKernel($kernel);
}
```

Starting from version 5.4 this was changed to be done through the configuration:

```yaml
# config/packages/framework.yaml
when@prod:
    framework:
        http_cache: true
```

However, it was never explained how the caching kernel can be extended in this case. Decorating the `http_cache` service seems like the best option.

Commits
-------

34809dd [HttpCache] Explain how to extend the HttpCache class
@nicolas-grekas nicolas-grekas deleted the http_cache branch May 10, 2025 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FrameworkBundle] allow enabling the HTTP cache using semantic configur…
3 participants