Skip to content

[WIP] Allow override of request cache headers #150

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

Closed
wants to merge 1 commit into from
Closed

[WIP] Allow override of request cache headers #150

wants to merge 1 commit into from

Conversation

gonzalovilaseca
Copy link

This PR corresponds to feature #99.
Any comments welcome (I know, tests are missing..)

@ddeboer
Copy link
Member

ddeboer commented Oct 3, 2014

Hmm, it seems the test failures are what we expect.

It seems you have removed your messages from #99. What exact error message do you get when running the tests locally?

@gonzalovilaseca
Copy link
Author

@ddeboer I had to install php with pear, after that it worked. I moved to phpspec long time ago and my phpunit skills have rusted

@ddeboer
Copy link
Member

ddeboer commented Oct 3, 2014

Okay, good to hear! Does that mean you can continue working on tests for this PR?

@gonzalovilaseca
Copy link
Author

I've modified existing tests to reflect new config changes.
I'm not familiar with phpunit so I can't seem to figure out how to do the following tests:

  1. Check that global 'overwrite' config is passed correctly to the subscriber rulesMap.
  2. Check that specific 'overwrite' config is passed correctly to the subscriber rulesMap.
  3. Check that if the control headers must be overwritten, the CacheControlSubscriber overwrites them.

Any other tests that I'm missing?

'private' => true,
'public' => true,
'private' => true,
'public' => true,
Copy link
Member

Choose a reason for hiding this comment

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

Please don't align =>. It does not add much value, and it is the perfect way to have coding standards enforcing merge conflicts more frequently by requiring whitespace changes on unrelated lines

@dbu
Copy link
Contributor

dbu commented Oct 6, 2014

this looks good, i agree with the idea and the implementation (except for the config details)

can you please document this feature in the relevant documentation sections? doc is in this repo under Resources/doc, and online at http://foshttpcachebundle.readthedocs.org/

) {
$response->headers->addCacheControlDirective($flag);
if (!empty($controls[$key])) {
if (!$response->headers->hasCacheControlDirective($flag) || $overwrite) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a code style question really, but i would prefer to write it as

if (!empty($controls[$key])
    && ($overwrite || !$response->headers->hasCacheControlDirective($flag))
) {

no need for two nested if statements. having $overwrite first as its way cheaper to check than the method call.

@dbu
Copy link
Contributor

dbu commented Oct 13, 2014

sorry for not responding. i was not aware that you pushed more commits. best write a comment after pushing, telling me to have a look if its good now ;-)

@gonzalovilaseca
Copy link
Author

PR updated, I'm going to check documentation now

@dbu
Copy link
Contributor

dbu commented Oct 14, 2014

cool. i think it just needs 1 or 2 places to mention in the doc, where a user would be glad to learn about this option.

@gonzalovilaseca
Copy link
Author

doc updated!

@dbu
Copy link
Contributor

dbu commented Oct 14, 2014

i did some cleanups and created a new PR as #151 - please provide feedback there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants