-
Notifications
You must be signed in to change notification settings - Fork 61
Add abstracted tag handling #237
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
Conversation
@@ -12,6 +12,9 @@ This library integrates your PHP applications with HTTP caching proxies such as | |||
Use this library to send invalidation requests from your application to the caching proxy | |||
and to test your caching and invalidation code against a Varnish setup. | |||
|
|||
It does this by abstracting some caching concepts and attempting to make sure these | |||
can be supported across Varnish, Nginx and Symfony HTTP Cache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i suggest:
... and Symfony HttpCache
.
@ddeboer can you please also give your input here? there are some architectural decisions to take, would appreciate your opinion. |
Did an attempt to move tag header name, value, and escaping down to cache invalidations. Looks a bit better imo. |
@@ -12,6 +12,9 @@ This library integrates your PHP applications with HTTP caching proxies such as | |||
Use this library to send invalidation requests from your application to the caching proxy | |||
and to test your caching and invalidation code against a Varnish setup. | |||
|
|||
It does this by abstracting some caching concepts and attempting to make sure these | |||
can be supported across Varnish, Nginx and Symfony HTTPCache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we wrote HttpCache elsewhere (the php class is written in camelcase)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
at this point, the only thing the TagHandler is doing is collecting the tags for tagging a response. that is really not much. i think we should either let TagHandler talk to the proxy client directly or get rid of the handler and move all to CacheInvalidator. i tend to keep TagHandler because its a whole topic of its own and not only about invalidation. I wonder if the TagInterface should be outside the Invalidation namespace, because it is not only about invalidating tags but also about tagging responses. |
ok, so then I'll skip the header related parts added to CacheInvalidator as well right? (given we then instead inject the tag "something in lack of calling it invalidator anymore" instance) |
sorry, still trying to get some input from @ddeboer what he thinks about
this one.
can we wait another day or two? if he does not respond by then we just
move forward with what we think is cleanest.
|
ok, no problem. Probably vacation :) |
That's right, I'm on holidays. Back in civilisation with proper internet connection in a week. :) |
@andrerom sorry to keep you waiting, but i would prefer to wait for the other david to be back before we take a decision on how to do this one. its a rather important architectural decision. |
No problem, opened a possible followup issue to discuss in the mean time (#241). |
@ddeboer any views on this topic? |
This looks promising. With this feature we could better optimise invalidation... |
* | ||
* @return array Sane tags. | ||
*/ | ||
protected function escapeTags(array $tags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this, and maybe some other parts will be needed for HttpCache as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
Very interesting! I agree with the general approach: we’ve been following Varnish terminology in differentiating purge, refresh and ban, but nothing is stopping is from introducing a separate tags type.
@andrerom Can you elaborate a bit on why you did this? Especially since @dbu and I decided earlier to move tag-specific logic out of the CacheInvalidator and into the TagHandler. |
I'll need to read up on the discussions above where @dbu and me hit some issues with first approach, but think it was among other things because some of the escaping was clearly varnish specific. |
Right, in the discussion (on outdated diffs) I read:
@dbu Did you mean here to move the tag header logic into In the current solution, |
|
||
This library provides decorators that build on top of the ``CacheInvalidator`` | ||
to simplify common operations. | ||
This library provides a service to handle tagging of responses ``ResponseTagger`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/service/helper/ ?
@dbu second pass |
================ | ||
|
||
This library provides a helper to handle tagging of responses ``ResponseTagger`` | ||
to simplify use of tags. The ``ResponseTagger`` helps you keep track tags for a response, which can be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the first line can simply be removed, it does not say anything more than the second line.
cool! can you adress these last two details and squash commits? then we can merge this. |
done |
Aims to allow support for tagging also on Symfomy HTTP Cache and potentially other caches by limiting the feature to focus on only tags and not any random header. Closes FriendsOfSymfony#234
~~Still failing on doc, as I don't know anything about rst, how is it supposed to work?~~~ fixed in bc36103 |
@@ -91,6 +91,15 @@ include that port in the base URL:: | |||
|
|||
$varnish = new Varnish($servers, 'my-cool-app.com:8080'); | |||
|
|||
-.. _varnish_custom_tags_header: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have a -
too much. the line should start with ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, copy past fail, hopefully fixed in bc36103
great job, thanks a lot for your patience! |
@dbu Likewise :) |
Aims to allow support for tagging also on Symfony HTTP Cache and
potentially other caches by limiting the feature to focus on only
tags and not random headers.
Closes #234