Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Help: can i use CDN to serve web API request
New on LowEndTalk? Please Register and read our Community Rules.

Help: can i use CDN to serve web API request

andikliveandiklive Member
edited November 2017 in General

Hi, i have question about CDN. Is CDN can serve api request with query string, the respone is json format.

I know its work (at cloudflare) with static content like:

/asset/style.css?ver=2

but can i use it to serve API request like:

/api/posts?id=1

/api/posts?id=2

/api/posts?q=web

so first request will save on CDN and next request will be serve by cdn and not request to my server again with some period of time (ex. 1 week). i use cloudflare page rules and seem not working. its that possible at other cdn service?

can you recomended CDN service thats support query string caching, PAYG model is prefered cause i dont use it massively at the moment. thanks

Comments

  • F21F21 Member
    edited November 2017

    I think most CDNs will allow you to configure whether you want to ignore the query string in the control panel. For example /api/posts?id=1 and /api/post?id=2 with the query string ignored will serve the same cached item or /api/post?id=1 and /api/post?id=2 taking the query string into account serves different cached items.

    In your case, I believe the query string is no different from using a URL segment depending on how your app is built in the backend, for example /api/posts?id=1 can also be served using /api/posts/1.

    If you're looking for a cheap PAYG CDN, have a look at 5CentsCDN. You get 1TB for free (it does not expire) and the per GB rate is also pretty reasonable. I switched from KeyCDN to 5CentsCDN myself and so far it seems pretty reasonable.

    Thanked by 1andiklive
  • andikliveandiklive Member
    edited November 2017

    @F21 said:
    I think most CDNs will allow you to configure whether you want to ignore the query string in the control panel. For example /api/posts?id=1 and /api/post?id=2 with the query string ignored will serve the same cached item or /api/post?id=1 and /api/post?id=2 taking the query string into account serves different cached items.

    In your case, I believe the query string is no different from using a URL segment depending on how your app is built in the backend, for example /api/posts?id=1 can also be served using /api/posts/1.

    If you're looking for a cheap PAYG CDN, have a look at 5CentsCDN. You get 1TB for free (it does not expire) and the per GB rate is also pretty reasonable. I switched from KeyCDN to 5CentsCDN myself and so far it seems pretty reasonable.

    so its possible, mostly is search post example /api/posts?q=web&cat=7 is it cacheable too? anyway do you ever try BunnyCDN, how about it.

  • F21F21 Member
    edited November 2017

    I have not tried BunnyCDN myself, but I have heard good things about it on here. The downside is that is that credits expire after a year unless you make a minimum payment of $10 each year.

    As for caching search results, it depends on how often the search content and ranking changes. I think search might be a bit too dynamic to cache over CDN, but if you do wish to do it, then it should be cacheable by the CDN. However, I would question the utility of caching the search results (i.e. are there going to be loads of people search for the keyword web in category 7, such that we really need to cache it on the CDN?). Another issue is that if your posts change, then you will need to purge all the search results.

  • actually it little bit tricky for my use case, i combine more than 2 different api (external) to serve request. so basically im listing article based on search, and its will save me to consume api from external api request.

    more 2 external api -> my api service -> website.

    and i dont have database for this, just use 3rd party api service. so it'll be save my resources, if i have database i'll use sphinxsearch instead of cdn. and i like set edge cache like 3-7days to get fresh result from 3rd party api service. and fyor posts its rarely changed, just for search it'll be have different result like how many listing article will be displayed etc.

  • You can set BunnyCDN to cache url.query string. @BunnySpeed

  • BecomeWebHost.com | ScreenShots WHM Reseller hosting + billing + support system + client area included...

  • i just try BunnyCDN 14 days free trial, so far its work with my use case. panel is user friendly like cloudflare rather than 5centscdn. i think i'll go with bunnycdn.

    i think i prefer cdn, cause is more easy to manage.

    Thanked by 1BecomeWebHost
  • I'm not sure if BunnyCDN works the way you want, but for static content it's really good. And I love the live monitoring view :D

    I haven't forgotten the stickers @BunnySpeed

  • BunnyCDN supports what you want, at least the query string caching part.

  • If the data is in json format, you can write a static file while creating a post. For example create /api/posts/1.json for /api/posts?id=1 while you create or update the post. I do it this way.

    Nothing for now :)

  • Hi there

    I've recently taken an account with 5centscdn pay as you go. I think by far, the plan is great as they provide 1TB free bandwidth also with $15 free credit, their delivery is also good when I had it tested.

    Seems their control panel is a bit slow, but their support is best.

    Had tried bunnycdn, but they have high latency in my location, testing with 5centscdn is ongoing and so far they seem good.

  • trewqtrewq Administrator, Moderator, Provider

    @james360 said:
    Hi there

    I've recently taken an account with 5centscdn pay as you go. I think by far, the plan is great as they provide 1TB free bandwidth also with $15 free credit, their delivery is also good when I had it tested.

    Seems their control panel is a bit slow, but their support is best.

    Had tried bunnycdn, but they have high latency in my location, testing with 5centscdn is ongoing and so far they seem good.

    5centscdn.com use shady marketing tactics by shilling using fake account. Buyer beware.

    Thanked by 4Yura WSS andiklive dyu
  • @trewq said:

    @james360 said:
    Hi there

    I've recently taken an account with 5centscdn pay as you go. I think by far, the plan is great as they provide 1TB free bandwidth also with $15 free credit, their delivery is also good when I had it tested.

    Seems their control panel is a bit slow, but their support is best.

    Had tried bunnycdn, but they have high latency in my location, testing with 5centscdn is ongoing and so far they seem good.

    5centscdn.com use shady marketing tactics by shilling using fake account. Buyer beware.

    I was going to sign up and then I saw that...

    Thanks @trewq

    Thanked by 1trewq
  • @trewq said:
    5centscdn.com use shady marketing tactics by shilling using fake account. Buyer beware.

    I heard that 5centcdn also has shady billing practices to afford their shills.

    Thanked by 1rush0143
  • I signed up and then read this comment. So far good with them as i got 15$ which i can use for up to 1 TB. will you keep posted.

  • hzrhzr Member, Moderator

    rush0143 said: I signed up and then read this comment. So far good with them as i got 15$ which i can use for up to 1 TB. will you keep posted.

    But bunnycdn is $10 per tb

  • @hzr said:

    rush0143 said: I signed up and then read this comment. So far good with them as i got 15$ which i can use for up to 1 TB. will you keep posted.

    But bunnycdn is $10 per tb

    Isn’t that only for NA/EU traffic? Asia bandwith would cost 3x as much

  • @hzr said:

    rush0143 said: I signed up and then read this comment. So far good with them as i got 15$ which i can use for up to 1 TB. will you keep posted.

    But bunnycdn is $10 per tb

    Yes, I am testing bunnycdn and keycdn as well as.

    5centscdn has a promo plan which i am testing, its $5 per tb

  • @muffin said:

    @hzr said:

    rush0143 said: I signed up and then read this comment. So far good with them as i got 15$ which i can use for up to 1 TB. will you keep posted.

    But bunnycdn is $10 per tb


    Isn’t that only for NA/EU traffic? Asia bandwith would cost 3x as much

    Yes, while comparing 5centscdn is cheaper as its globally one price on all plans.

    I will review once i complete testing.

Sign In or Register to comment.