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

X-Page-Usage in response header #127

Open
sridharraman opened this issue Mar 18, 2017 · 5 comments
Open

X-Page-Usage in response header #127

sridharraman opened this issue Mar 18, 2017 · 5 comments

Comments

@sridharraman
Copy link

Hi

As per the Facebook Messenger documentation (https://developers.facebook.com/blog/post/2016/06/16/page-level-rate-limits/), the response header contains additional information:

The values for call_count, total_cputime and total_time are whole numbers representing the percentage used values for each of the metrics.

Is there any way of accessing these header values using this gem?

Thanks,
Sridhar

@jgorset
Copy link
Owner

jgorset commented Mar 20, 2017

Not yet, but I'd be happy to merge a pull requests that does that!

@cfurrow
Copy link
Contributor

cfurrow commented Feb 12, 2018

In my own testing, I've not seen this header, X-Page-Usage, come through yet in responses from Facebook to my webhook endpoint. I've not released my app/bot yet, so it's possible they do not send while the app is in development mode.

@cfurrow
Copy link
Contributor

cfurrow commented Feb 20, 2018

I looked for the X-Page-Usage headers when sending a message over the api, and receiving a response from Facebook, and that header was not present in the response. Not sure where they come into play.

Example headers from FB after sending a message successfully to Facebook's API:

{
  "access-control-allow-origin"=>["*"], 
  "pragma"=>["no-cache"], 
  "cache-control"=>["private, no-cache, no-store, must-revalidate"], 
  "facebook-api-version"=>["v2.11"], 
  "expires"=>["Sat, 01 Jan 2000 00:00:00 GMT"], 
  "x-fb-rev"=>["3659829"], 
  "content-type"=>["text/javascript; charset=UTF-8"], 
  "x-fb-trace-id"=>["snipped"], 
  "strict-transport-security"=>["max-age=15552000; preload"], 
  "x-fb-debug"=>["snipped characters"], 
  "date"=>["Tue, 20 Feb 2018 14:40:50 GMT"], 
  "connection"=>["close"], 
  "content-length"=>["85"]
}

@cfurrow
Copy link
Contributor

cfurrow commented Feb 20, 2018

Reading the FB docs, I now see why I'm not seeing that header yet:

If enough calls are being made on behalf of a page to be considered for rate limiting by our system, we return an X-Page-Usage HTTP header.

So if you are approaching that rate limit, THEN Facebook includes that header in the response. Rate limits are divided between app and Facebook pages:

  • 200 calls per user, per hour, for apps
  • A total of 4800 calls per daily engaged users. 24hr window slides and is updated every minute.

@jgorset
Copy link
Owner

jgorset commented Mar 11, 2018

Alright, cool, that makes sense!

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

No branches or pull requests

3 participants