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

Generic CDN support #457

Closed
diimpp opened this issue Jun 20, 2019 · 5 comments
Closed

Generic CDN support #457

diimpp opened this issue Jun 20, 2019 · 5 comments

Comments

@diimpp
Copy link

diimpp commented Jun 20, 2019

Hello,

I'm tasked with implementing CloudFlare cache invalidation and I've noticed, that HttpProxyClient design is not really compatible with generic CDN cache invalidation flow.

What usually happens with CDN is rest post request with json body. Single or multiple urls, headers, etc.

And for example it's not possible to supply body to the request factory of the HttpProxyCache
https://github.com/FriendsOfSymfony/FOSHttpCache/blob/master/src/ProxyClient/HttpProxyClient.php#L94

I do realise, that I can just implement ProxyClient interface and do the rest of the implementation as I need to.
And that HttpProxyClient is not generic solution, but a specialized version for direct communication with proxy servers line nginx or varnish, but it's kind of feels wrong to have HttpProxyClient name wise, while it doesn't allow to send body.

Not sure what this issue is about. :) RFC for renaming HttpProxyClient? Add some mention on CDN's or custom ProxyClient implementation?

CF purge request looks like so

curl -X POST "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/purge_cache" \
     -H "X-Auth-Email: user@example.com" \
     -H "X-Auth-Key: abcdefg" \
     -H "Content-Type: application/json" \
     --data '{"files":["http://www.example.com/css/styles.css",{"url":"http://www.example.com/cat_picture.jpg","headers":{"Origin":"cloudflare.com","CF-IPCountry":"US","CF-Device-Type":"desktop"}}]}'

Related #142
#403

@dbu
Copy link
Contributor

dbu commented Jun 20, 2019

hi, great to hear this! @andrerom is looking into fastly support (see #451), which is also a CDN. i think he noticed similar needs. @Toflar is working on litespeed support (see #444), which again asks us to make some concepts more flexible. i would love for FOSHttpCache to be more flexible for these scenarios. please start by looking at the fastly PR to see if that already addresses some of your concerns. we could also extract some refactorings from there and merge early (e.g. allow request body), so that you both can continue the work on CDN support.

@andrerom
Copy link
Contributor

andrerom commented Nov 27, 2019

@simonrjones
Copy link
Contributor

I've added Cloudflare support for a project we're working on and it would be great to add this into FOSHttpCache. Not sure if I should add a new issue, but I thought I'd comment here since this issue seems related.

#507

@diimpp
Copy link
Author

diimpp commented Dec 20, 2021

HttpProxyClient allows to send body since #451 and library have two CDN integrations since then: Fastly and CloudFlare.

Seems issue is solved now. 🔥

@diimpp diimpp closed this as completed Dec 20, 2021
@dbu
Copy link
Contributor

dbu commented Dec 20, 2021

thanks @simonrjones - lets discuss the addition in your PR directly, no need for an issue for that ;-)

and thanks @diimpp for cleaning up here.

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

No branches or pull requests

4 participants