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

Cached responses yield 412 Precondition Failed #70

Closed
davidmuzi opened this issue Mar 9, 2017 · 2 comments
Closed

Cached responses yield 412 Precondition Failed #70

davidmuzi opened this issue Mar 9, 2017 · 2 comments
Labels
help wanted Issues the Apollo team would love help from the community about

Comments

@davidmuzi
Copy link

I created an app using Githubs API, and noticed that the default cache policy was preventing all but the first request to succeed.

Failed response:

<NSHTTPURLResponse: 0x610000039940> { URL: https://github.com/gitapi/graphql } { status code: 412, headers {
    "Access-Control-Allow-Origin" = "*";
    "Access-Control-Expose-Headers" = "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval";
    "Cache-Control" = "private, max-age=60, s-maxage=60";
    "Content-Length" = 0;
    "Content-Security-Policy" = "default-src 'none'";
    "Content-Type" = "text/html;charset=utf-8";
    Date = "Thu, 09 Mar 2017 14:27:52 GMT";
    Etag = "\"4853e207b0ae85065437a2f600a2d1aa\"";
    Server = "GitHub.com";
    Status = "412 Precondition Failed";
    "Strict-Transport-Security" = "max-age=31536000; includeSubdomains; preload";
    Vary = "Accept, Authorization, Cookie, X-GitHub-OTP";
    "X-Content-Type-Options" = nosniff;
    "X-Frame-Options" = deny;
    "X-GitHub-Request-Id" = "CF6E:32C5:2B947BF:3797DE8:58C16668";
    "X-RateLimit-Limit" = 200;
    "X-RateLimit-Remaining" = 195;
    "X-RateLimit-Reset" = 1489072275;
    "X-XSS-Protection" = "1; mode=block";
} }

If I set configuration.requestCachePolicy = .reloadIgnoringLocalCacheData the issue goes away

https://github.com/davidmuzi/graphql-ios-presentation/blob/2-queries/Projects/Projects/MasterViewController.swift#L25 (edited)

The httpBody and requestHeaders appear identical before the sessionTask is executed

@martijnwalraven martijnwalraven added the help wanted Issues the Apollo team would love help from the community about label Mar 15, 2017
@martijnwalraven
Copy link
Contributor

See ongoing discussion at the GitHub forum.

We should probably either disable HTTP caching by default or find a way to deal with 412 responses ourselves.

@davidmuzi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues the Apollo team would love help from the community about
Projects
None yet
Development

No branches or pull requests

2 participants