Skip to content

Conversation

@opatry
Copy link
Owner

@opatry opatry commented May 8, 2025

When testing with 2 consecutive calls to https://httpbin.org/cache, I get 200 OK and 304 NOT MODIFIED as expected. That being said, when using Google Tasks API, I only get 200… maybe server doesn't provide Http Caching?

With httpbin requests:

REQUEST: https://httpbin.org/cache
METHOD: GET
COMMON HEADERS
-> Accept: application/json
-> Accept-Charset: UTF-8
-> Accept-Encoding: gzip
-> Authorization: Bearer xxxx
-> User-Agent: curl/7.61.0
CONTENT HEADERS
-> Content-Length: 0
RESPONSE: 200 OK
METHOD: GET
FROM: https://httpbin.org/cache
COMMON HEADERS
-> Access-Control-Allow-Credentials: true
-> Access-Control-Allow-Origin: *
-> Connection: keep-alive
-> Content-Length: 591
-> Content-Type: application/json
-> Date: Thu, 08 May 2025 18:58:23 GMT
-> ETag: 4e488dc9a19e48f884cfca5e77607599
-> Last-Modified: Thu, 08 May 2025 18:58:23 GMT
-> Server: gunicorn/19.9.0
=======================================================================================
REQUEST: https://httpbin.org/cache
METHOD: GET
COMMON HEADERS
-> Accept: application/json
-> Accept-Charset: UTF-8
-> Accept-Encoding: gzip
-> Authorization: Bearer xxxx
-> If-Modified-Since: Thu, 08 May 2025 18:58:23 GMT
-> If-None-Match: 4e488dc9a19e48f884cfca5e77607599
-> User-Agent: curl/7.61.0
CONTENT HEADERS
-> Content-Length: 0
RESPONSE: 304 NOT MODIFIED
METHOD: GET
FROM: https://httpbin.org/cache
COMMON HEADERS
-> Access-Control-Allow-Credentials: true
-> Access-Control-Allow-Origin: *
-> Connection: keep-alive
-> Date: Thu, 08 May 2025 18:58:26 GMT
-> Server: gunicorn/19.9.0

With Google Tasks requests:

REQUEST: https://tasks.googleapis.com/tasks/v1/users/@me/lists
METHOD: GET
COMMON HEADERS
-> Accept: application/json
-> Accept-Charset: UTF-8
-> Accept-Encoding: gzip
-> Authorization: Bearer xxxx
-> User-Agent: curl/7.61.0
CONTENT HEADERS
-> Content-Length: 0
RESPONSE: 200 OK
METHOD: GET
FROM: https://tasks.googleapis.com/tasks/v1/users/@me/lists
COMMON HEADERS
-> Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
-> Content-Type: application/json; charset=UTF-8
-> Date: Thu, 08 May 2025 18:55:57 GMT
-> ETag: "jN-nxpZbjK0"
-> Server: ESF
-> Transfer-Encoding: chunked
-> Vary: Origin; X-Origin; Referer
-> X-Content-Type-Options: nosniff
-> X-Frame-Options: SAMEORIGIN
-> X-XSS-Protection: 0
-> x-l2-request-path: l2-managed-14
=======================================================================================
REQUEST: https://tasks.googleapis.com/tasks/v1/users/@me/lists
METHOD: GET
COMMON HEADERS
-> Accept: application/json
-> Accept-Charset: UTF-8
-> Accept-Encoding: gzip
-> Authorization: Bearer xxxx
-> If-None-Match: "jN-nxpZbjK0"
-> User-Agent: curl/7.61.0
CONTENT HEADERS
-> Content-Length: 0
RESPONSE: 200 OK
METHOD: GET
FROM: https://tasks.googleapis.com/tasks/v1/users/@me/lists
COMMON HEADERS
-> Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
-> Content-Type: application/json; charset=UTF-8
-> Date: Thu, 08 May 2025 18:55:58 GMT
-> ETag: "jN-nxpZbjK0"
-> Server: ESF
-> Transfer-Encoding: chunked
-> Vary: Origin; X-Origin; Referer
-> X-Content-Type-Options: nosniff
-> X-Frame-Options: SAMEORIGIN
-> X-XSS-Protection: 0
-> x-l2-request-path: l2-managed-14

Checklist

  • I have read the CONTRIBUTING guide
  • Code compiles correctly
  • Created tests which fail without the change (if possible)
  • All tests passing

When testing with 2 consecutive calls to https://httpbin.org/cache, I get 200 OK and 304 NOT MODIFIED as expected.
That being said, when using Google Tasks API, I only get 200… maybe server doesn't provide Http Caching?
@opatry opatry merged commit 9fe9899 into main May 8, 2025
2 checks passed
@opatry opatry deleted the ktor-http-caching branch May 8, 2025 19:01
@opatry
Copy link
Owner Author

opatry commented May 8, 2025

It appears, I finally got some 304 responses 🎉
Might depends on endpoints.

Typically, listing of tasks seems to allow caching 👍

[2025-05-08T19:05:14.468357Z][info] REQUEST: https://tasks.googleapis.com/tasks/v1/users/@me/lists?maxResults=100
METHOD: GET
[2025-05-08T19:05:14.748332Z][info] RESPONSE: 200 OK
METHOD: GET
FROM: https://tasks.googleapis.com/tasks/v1/users/@me/lists?maxResults=100
[2025-05-08T19:05:14.757835Z][info] REQUEST: https://tasks.googleapis.com/tasks/v1/lists/MTAwNDEyMDI1NDY0NDEwNzQ0NDI6MDow/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
METHOD: GET
[2025-05-08T19:05:15.021078Z][info] RESPONSE: 304 Not Modified
METHOD: GET
FROM: https://tasks.googleapis.com/tasks/v1/lists/MTAwNDEyMDI1NDY0NDEwNzQ0NDI6MDow/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
[2025-05-08T19:05:15.045179Z][info] REQUEST: https://tasks.googleapis.com/tasks/v1/lists/OXl0d1JibXgyeW1zWWFIMw/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
METHOD: GET
[2025-05-08T19:05:15.403740Z][info] RESPONSE: 304 Not Modified
METHOD: GET
FROM: https://tasks.googleapis.com/tasks/v1/lists/OXl0d1JibXgyeW1zWWFIMw/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
[2025-05-08T19:05:15.423419Z][info] REQUEST: https://tasks.googleapis.com/tasks/v1/lists/UFd4NktUODJJbjNCX3J0aQ/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
METHOD: GET
[2025-05-08T19:05:15.711710Z][info] RESPONSE: 304 Not Modified
METHOD: GET
FROM: https://tasks.googleapis.com/tasks/v1/lists/UFd4NktUODJJbjNCX3J0aQ/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
[2025-05-08T19:05:15.723765Z][info] REQUEST: https://tasks.googleapis.com/tasks/v1/lists/MEg4NVpsZXlDelZDbnV4Xw/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
METHOD: GET
[2025-05-08T19:05:16.017678Z][info] RESPONSE: 304 Not Modified
METHOD: GET
FROM: https://tasks.googleapis.com/tasks/v1/lists/MEg4NVpsZXlDelZDbnV4Xw/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
[2025-05-08T19:05:16.021149Z][info] REQUEST: https://tasks.googleapis.com/tasks/v1/lists/YVpoQ29QaTFtLWE4bVRPSg/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
METHOD: GET
[2025-05-08T19:05:16.282570Z][info] RESPONSE: 304 Not Modified
METHOD: GET
FROM: https://tasks.googleapis.com/tasks/v1/lists/YVpoQ29QaTFtLWE4bVRPSg/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
[2025-05-08T19:05:16.288025Z][info] REQUEST: https://tasks.googleapis.com/tasks/v1/lists/NE1oSEp5MmpmbXl3Sm1iZA/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
METHOD: GET
[2025-05-08T19:05:16.575660Z][info] RESPONSE: 304 Not Modified
METHOD: GET
FROM: https://tasks.googleapis.com/tasks/v1/lists/NE1oSEp5MmpmbXl3Sm1iZA/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
[2025-05-08T19:05:16.585245Z][info] REQUEST: https://tasks.googleapis.com/tasks/v1/lists/NjdVc0lJSEJ0Znc3S1pPNQ/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false
METHOD: GET
[2025-05-08T19:05:16.856464Z][info] RESPONSE: 304 Not Modified
METHOD: GET
FROM: https://tasks.googleapis.com/tasks/v1/lists/NjdVc0lJSEJ0Znc3S1pPNQ/tasks?maxResults=100&showCompleted=true&showDeleted=false&showHidden=true&showAssigned=false

@opatry opatry linked an issue May 12, 2025 that may be closed by this pull request
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

Successfully merging this pull request may close these issues.

Use HTTP caching 💾

2 participants