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

Cache of POST with same url and different body #61

Closed
xyhuangjinfu opened this issue Jul 25, 2017 · 2 comments
Closed

Cache of POST with same url and different body #61

xyhuangjinfu opened this issue Jul 25, 2017 · 2 comments

Comments

@xyhuangjinfu
Copy link
Contributor

Because of the mWaitingRequests field of RequestQueue, several Request which have same url and different body, the others request can only be executed after the first Request return. I think this is a little unreasonable, can mWaitingRequests only work for GET method? Common HTTP caches are typically limited to caching responses to GET.

@xyhuangjinfu
Copy link
Contributor Author

xyhuangjinfu commented Jul 25, 2017

something like this.

public <T> Request<T> add(Request<T> request) {
    //other operations
     if (request.getMethod() != Request.Method.GET && request.getMethod() != Request.Method.DEPRECATED_GET_OR_POST) {
	    mCacheQueue.add(request);
	    return request;
	}
    synchronized (mWaitingRequests) {
            //other operations
    }
}

@jpd236
Copy link
Collaborator

jpd236 commented Jul 26, 2017

Why not just call setShouldCache(false) on your requests if you don't want them to be cached? That will bypass mWaitingRequests, and doesn't involve a potentially incorrect assumption that POST requests shouldn't be cached.

@jpd236 jpd236 closed this as completed Jul 26, 2017
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

2 participants