Skip to content
This repository has been archived by the owner on Sep 18, 2018. It is now read-only.

Cache /api/live/happening_now. #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

kjoconnor
Copy link
Contributor

This is requested 800-1000/s at peak and rarely changes.

I'm open to suggestions on time! Just guessed at 300s but we might want to lower it.

👓 @spladug

This is requested 800-1000/s at peak and rarely changes.
Copy link
Contributor

@spladug spladug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to confirm: when testing this locally do you see the right header in place? I'm concerned that reddit_base is going to override it for logged-in users and put the anti-poisoning headers in place instead.

@kjoconnor
Copy link
Contributor Author

Here's /r/all.json (note no cache-control header):

KevinsMacBookPro:~ kevin$ curl --verbose  "https://reddit.local/r/all.json" > /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 172.28.128.3...
* TCP_NODELAY set
* Connected to reddit.local (172.28.128.3) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [102 bytes data]
* NPN, negotiated HTTP1.1
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [770 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [333 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Unknown (67):
} [36 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: CN=reddit.local
*  start date: Jul 25 22:46:45 2018 GMT
*  expire date: Dec  7 22:46:45 2019 GMT
*  subjectAltName: host "reddit.local" matched cert's "reddit.local"
*  issuer: CN=reddit.local
*  SSL certificate verify ok.
> GET /r/all.json HTTP/1.1
> Host: reddit.local
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 27 Jul 2018 20:50:47 GMT
< Content-Type: application/json; charset=UTF-8
< Content-Length: 92859
< Connection: keep-alive
< Server: PasteWSGIServer/0.5 Python/2.7.6
< x-ua-compatible: IE=edge
< x-frame-options: SAMEORIGIN
< x-content-type-options: nosniff
< x-xss-protection: 1; mode=block
< x-ratelimit-remaining: 294
< x-ratelimit-used: 6
< x-ratelimit-reset: 553
< set-cookie: loid=00000000000000000s.2.1532724647405.Z0FBQUFBQmJXNFdueTVGc04zdkRFRGMxMmpyaVBKaTdTSTBlV3VIUS1HM0FkSGZnWTRyXzVOX2h3UHBkaFlkbklwS2JtRmpsVlJadlVHdnhyUGFMVnROSXNWWnNncmc4d190VzFKU2xvaWI0cXlLOEVFUDRZU3hSa1pjOF82WHhuQjZxWk92UXlpR0g; Domain=reddit.local; Max-Age=63071999; Path=/; expires=Sun, 26-Jul-2020 20:50:47 GMT; secure
< set-cookie: session_tracker=UmZ6OU8gogBdSBIwW7.0.1532724647402.Z0FBQUFBQmJXNFduY3ZSLVpIaV82amFhN3kxOE5jdkxpTnZsYm50MzNVVW1xYnZIcW9rdEd0TWJmallHXzlINlBhTnJkME1sVF9zdFNlZ3gwNE1mbU4tam5LREJlQW1YdFVaU3ZpWjBkamF3aWtRMEM2VzRtWFdNa21zOS0yRDZGT2dreHkzUmpseEQ; Domain=reddit.local; Max-Age=7199; Path=/; expires=Fri, 27-Jul-2018 22:50:47 GMT; secure
< access-control-allow-origin: *
< access-control-expose-headers: X-Moose
<
{ [15249 bytes data]
100 92859  100 92859    0     0   324k      0 --:--:-- --:--:-- --:--:--  325k
* Connection #0 to host reddit.local left intact

vs /api/live/happening_now.json with the header:

KevinsMacBookPro:~ kevin$ curl --verbose "https://reddit.local/api/live/happening_now.json" > /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 172.28.128.3...
* TCP_NODELAY set
* Connected to reddit.local (172.28.128.3) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [102 bytes data]
* NPN, negotiated HTTP1.1
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [770 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [333 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Unknown (67):
} [36 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: CN=reddit.local
*  start date: Jul 25 22:46:45 2018 GMT
*  expire date: Dec  7 22:46:45 2019 GMT
*  subjectAltName: host "reddit.local" matched cert's "reddit.local"
*  issuer: CN=reddit.local
*  SSL certificate verify ok.
> GET /api/live/happening_now.json HTTP/1.1
> Host: reddit.local
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 204 No Content
< Date: Fri, 27 Jul 2018 20:53:50 GMT
< Content-Type: application/json; charset=UTF-8
< Content-Length: 0
< Connection: keep-alive
< Server: PasteWSGIServer/0.5 Python/2.7.6
< x-ua-compatible: IE=edge
< cache-control: max-age=300
< x-frame-options: SAMEORIGIN
< x-content-type-options: nosniff
< x-xss-protection: 1; mode=block
< x-ratelimit-remaining: 293
< x-ratelimit-used: 7
< x-ratelimit-reset: 370
< set-cookie: loid=00000000000000000t.2.1532724830563.Z0FBQUFBQmJXNFplbi10b2Z0S2VIeHZEVW9JZjVqVWQ1WGhaN0hzdVNUZ3VBTWpKZThJRmZ4T1drRnZUMDEwTTdkajR5RVVjVFNIY1BmM2JjXzZLSTliR0E0bmx3UndXM1cydlFqOUdMUl9sZ1h1MGh6d0tXUzZkVXdjS3RZbkpWWXlZcmxEVWFjOWQ; Domain=reddit.local; Max-Age=63071999; Path=/; expires=Sun, 26-Jul-2020 20:53:50 GMT; secure
< set-cookie: session_tracker=bSxtQgPB2pV7rP2FjB.0.1532724830561.Z0FBQUFBQmJXNFplM0J2Y1pTbFhMb1lLejNtaG1uNWEtRVctOGdQV3o4eHluVk1CQXBuUVVkSUlIMHJaVEJmNlIyd2NlN2wxOWR1NlpYUUpPSHlPSU9aR0pOU0dzazFSUmE3a0YzSUtOczFyVHVGSHRzMzBHVVJuRHo1OFROTmhXNTFWOWNzOVdQekE; Domain=reddit.local; Max-Age=7199; Path=/; expires=Fri, 27-Jul-2018 22:53:50 GMT; secure
< access-control-allow-origin: *
< access-control-expose-headers: X-Moose
<
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connection #0 to host reddit.local left intact

💇‍♂️

@kjoconnor
Copy link
Contributor Author

Oh let me try logged in though...

@spladug
Copy link
Contributor

spladug commented Jul 27, 2018

👍 logged-in is the worry case 💅

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

Successfully merging this pull request may close these issues.

2 participants