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

The first request made "is not" cached #627

Closed
13steinj opened this issue Jul 17, 2016 · 3 comments
Closed

The first request made "is not" cached #627

13steinj opened this issue Jul 17, 2016 · 3 comments

Comments

@13steinj
Copy link
Contributor

I'm unsure if this is intended or just by consequence. I found this while writing up some tests for a Betamax-like package for python's httplib, and I was comparing responses with those from praw for the sake of ease.

I'll split this up into three scenarios:

  1. No authentication: The first request "is" cached by the handler, however reddit adds the "__cfduid" (I don't know what this does from a cursory look), "loid" (logged out id cookie for A/b tests), and "loidcreated" (timestamp of the LOid cookie creation so that reddit can change your variant test after a set amount of time) cookies to the requests Session cookiejar. Because of this, a request to the same url right after this does not read from the cache (as the cookies do not match, obviously).
  2. OAuth2 authentication: Same as scenario 1, except it's not the first request, it's the first request after authenticating.
  3. Login authentication: Same as scenario 1, except "reddit_session" and "secure_session" cookies are also added.

Sometimes a session_id cookie is also added, however this seems to be for anonymous tracking purposes and doesn't occur all the time.

Regardless the addition of these cookies make it so that the initial request, when stored in the DefaultHandler's cache, would never be retrieved from the cache (unless you manually manipulate the cookiejar)

@bboe
Copy link
Member

bboe commented Jul 17, 2016

Does this observation cause any problems? If not then I don't think we should worry about it. Also the client side cache has been removed in PRAW4.

How much have you looked into PRAW4? It would be really awesome to have a prioritized list of what features you require to get your scripts ported so we can move on from PRAW3.

@13steinj
Copy link
Contributor Author

13steinj commented Jul 17, 2016

It hasn't caused any problems for me, just noticed that it was a weird occurrence and could be troublesome in extreme cases (ex, writing a script that goes into reddit unauthenticated to view the logged out /new page of a subreddit (step1), authenticating with oauth to get the logged in view (step2), logging out and then rerequesting the page(step3), then when comparing step1 may not be equal to step3, even though assuming the use of the DefaultHandler it should be). And the fact that it's removed from PRAW4 altogether is a good call in my opinion anyway.

@bboe
Copy link
Member

bboe commented Jul 17, 2016

Let's not worry about it unless it actually results in a bug for someone. I'm not going to say don't try to fix it, but I think there are higher priority things worth spending time on. Closing for now.

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