Skip to content

[FrameworkBundle] allow enabling the HTTP cache using semantic configuration #37351

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
Jun 22, 2020

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jun 19, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

Right now, using the HTTP cache requires tweaking the public/index.php file as explained in the doc.

This PR removes this requirement by allowing one to do this instead:

framework:
    http_cache: true

@nicolas-grekas nicolas-grekas added this to the next milestone Jun 19, 2020
@nicolas-grekas nicolas-grekas changed the title [FrameworkBundle] allow enabling the HTTP cache using semantic config… [FrameworkBundle] allow enabling the HTTP cache using semantic configuration Jun 19, 2020
@javiereguiluz
Copy link
Member

This looks nice 👍 Thanks for the config example in the description. This will help the Doc team when this feature has to be documented.

Copy link
Member

@yceruto yceruto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea, thanks !

@nicolas-grekas
Copy link
Member Author

PR is ready.

@maxhelias
Copy link
Contributor

Nice! I love the idea 👍

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Jun 21, 2020

Since creating HttpCache outside of the framework was done for perf purpose, I did some benchmarks.
Here are my numbers:

Enabling point index.php framework.yaml
Without preloading 2150 r/s 1680 r/s
With preloading 2400 r/s 2315 r/s

@chalasr chalasr added the Ready label Jun 22, 2020
@fabpot
Copy link
Member

fabpot commented Jun 22, 2020

Thank you @nicolas-grekas.

fabpot added a commit that referenced this pull request Jun 23, 2020
…ing semantic configuration (nicolas-grekas)

This PR was merged into the 5.2-dev branch.

Discussion
----------

[FrameworkBundle] allow configuring trusted proxies using semantic configuration

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | -
| Tickets       | -
| License       | MIT
| Doc PR        | -

On top of the improved DX this should provide, this PR (and #37351) will allow [removing the corresponding lines](symfony/recipes#790) from `index.php` & recipes.

Using values:
```yaml
framework:
    trusted_proxies: '127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16'
#or
    trusted_proxies: '%env(TRUSTED_PROXIES)%'
```

`trusted_headers` is similar but is an array of headers to trust.
```yaml
framework:
    # that's the defaults already
    trusted_headers: ['x-forwarded-all', '!x-forwarded-host', '!x-forwarded-prefix']
```

Commits
-------

af9dd52 [FrameworkBundle] allow configuring trusted proxies using semantic configuration
->arrayNode('private_headers')
->performNoDeepMerging()
->requiresAtLeastOneElement()
->fixXmlConfig('private_header')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must be on the parent node to work

->integerNode('default_ttl')->end()
->arrayNode('private_headers')
->performNoDeepMerging()
->requiresAtLeastOneElement()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would we require at least one element here ?

@nicolas-grekas nicolas-grekas modified the milestones: next, 5.2 Oct 5, 2020
@fabpot fabpot mentioned this pull request Oct 5, 2020
fabpot added a commit that referenced this pull request Oct 16, 2020
…ion (nicolas-grekas)

This PR was merged into the 5.x branch.

Discussion
----------

[FrameworkBundle] fix config declaration of http_cache option

| Q             | A
| ------------- | ---
| Branch?       | 5.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Addresses comments from @stof in #37351 (review)

Commits
-------

2514cf1 [FrameworkBundle] fix config declaration of http_cache option
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull request Oct 16, 2020
…ion (nicolas-grekas)

This PR was merged into the 5.x branch.

Discussion
----------

[FrameworkBundle] fix config declaration of http_cache option

| Q             | A
| ------------- | ---
| Branch?       | 5.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Addresses comments from @stof in symfony/symfony#37351 (review)

Commits
-------

2514cf1c1d [FrameworkBundle] fix config declaration of http_cache option
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.

8 participants