Skip to content
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

[WIP][RFC] Fastly support #403

Closed
wants to merge 2 commits into from
Closed

[WIP][RFC] Fastly support #403

wants to merge 2 commits into from

Conversation

hpatoio
Copy link
Contributor

@hpatoio hpatoio commented Jan 19, 2018

@dbu
Copy link
Contributor

dbu commented Jan 23, 2018

thanks for starting this! i am super busy before php benelux, will try to have a look at this next week.

do you have specific questions at this point? what remains to be done (apart from test and style issues)?

@hpatoio
Copy link
Contributor Author

hpatoio commented Feb 1, 2018

do you have specific questions at this point?

No, not really

what remains to be done (apart from test and style issues)?

The FastlyProxyClient need implements:

  • TagCapable
  • PurgeCapable
  • RefreshCapable

And then documentation.

@dbu
Copy link
Contributor

dbu commented Feb 7, 2018

cool. then i will ignore that pull request for now, please ping me when you need input or want me to review something. i would love to have fastly support in this library!

}

foreach (\explode(",", $this->options['service_identifier']) as $fastlyServiceId) {
foreach ($tags as $tag) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In the case of hard purge, it's possible to invalidate 256 tags at a time now:
https://docs.fastly.com/api/purge#purge_db35b293f8a724717fcf25628d713583

Copy link
Contributor

@andrerom andrerom Nov 27, 2018

Choose a reason for hiding this comment

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

Seems they are also able to do this on Soft purge, via support there they seem to plan to update doc to make it more clear.

So given Fastly has API rate limits, we should change to use the API linked to above regardless of soft/purge so we can purge up to 256 tags at a time severely reducing risk of hitting API limits.

@andrerom
Copy link
Contributor

andrerom commented Oct 1, 2018

I think we might have another todo here. From what I could see last week, UserContextInvalidator also needs to be changed to not rely on BanCable for this to be possible.

One alternative would be to add tags for user id and session id on the hash request cache. Any thoughts on this @dbu ?

@dbu
Copy link
Contributor

dbu commented Oct 1, 2018

so it would be possible to do user context caching with fastly, if we find a way around the ban issue? that would be quite cool indeed.

how do we do that with the symfony cache kernel thingy? that one does not have full banning implemented, but does have tags. do we not invalidate the hash lookup for that case?

@dbu
Copy link
Contributor

dbu commented Oct 1, 2018

tagging the hash lookup response with the session id would be a very good idea imho. with the xkey extension, invalidating the tag would also be much better for varnish than the ban request that we currently do. (apart from that ban request being completely broken and banning the whole server each time)

@andrerom
Copy link
Contributor

andrerom commented Oct 1, 2018

how do we do that with the symfony cache kernel thingy? that one does not have full banning implemented, but does have tags. do we not invalidate the hash lookup for that case?

Unsure how it is done here, maybe @Toflar remember?

@Toflar
Copy link
Contributor

Toflar commented Oct 1, 2018

The Symfony Proxy is not BanCapable but I'm not sure what the question here is?

@andrerom
Copy link
Contributor

andrerom commented Oct 1, 2018

The Symfony Proxy is not BanCapable but I'm not sure what the question here is?

Q: How Use Context hash invalidation is done with Symfony Proxy, given UserContextInvalidator in bundle expects BanCapable, which Symfony Proxy does not implement.

At least I got issue with that when trying to do Fastly POC using cache_manager.custom_proxy_client.


@dbu While on that, I also ran into another possible thing we should think about for full Fastly support. And that is find a way to map FOS's reverse_proxy_ttl header to Fastly's Surrogate-Control header: https://docs.fastly.com/guides/performance-tuning/controlling-caching#changing-caching-times-for-different-users

@Toflar
Copy link
Contributor

Toflar commented Oct 1, 2018

I'm not using the User Context at all, I'm using our https://github.com/terminal42/header-replay-bundle. So I think this probably doesn't work?

@dbu
Copy link
Contributor

dbu commented Oct 1, 2018

user context

i found it: https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/blob/98280a84704952c9730128e29844f9b9fe6ea3e8/src/DependencyInjection/Configuration.php#L117-L140

we indeed require a ban capable client. in the default auto setting, we enable the logout handler for varnish, noop and when a custom proxy client is configured.
if we would change the hash lookup response to be tagged with the session id, we could use tag invalidation which works at least as well with varnish (with xkey its an improvement) and it would then also work with the symfony cachekernel.

so in short, i think we should do that (better in a separate pull request). given that user context logout handling never worked properly even for varnish, i think we can do this in a minor version and do not need a major version.

reverse_proxy_ttl

the X-Reverse-Proxy-TTL header is currently hardcoded in CacheControlListener: https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/blob/98280a84704952c9730128e29844f9b9fe6ea3e8/src/EventListener/CacheControlListener.php#L136

we should introduce a configuration to switches to the surrogate control mode and do the switch automatically if the fastly client is the default client. for the next major version, i think we should switch all proxies to use the surrogate-control header for this information, as that standard seems to cover this. thats better than using a custom header. but thats a BC break, so supporting both modes for now and deprecating the old mode would be the best upgrade path.

@andrerom
Copy link
Contributor

andrerom commented Oct 2, 2018

+100

@dbu
Copy link
Contributor

dbu commented Oct 5, 2018

meanwhile we use cache tagging for the context hash response in master.

do you plan to work on any of the subjects we discussed here @andrerom to wrap up fastly support?

@andrerom
Copy link
Contributor

andrerom commented Oct 8, 2018

do you plan to work on any of the subjects we discussed here @andrerom to wrap up fastly support?

I haven't planned for that, what I did for demo at symfony live can be found here. It's not tested against Fastly funtionally, but it has support for purging several tags at once when doing hard purging which can also be added here, but besides that it's very similar to the code here.

@dbu
Copy link
Contributor

dbu commented Aug 8, 2019

continued in #451

@dbu dbu closed this Aug 8, 2019
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.

None yet

4 participants