Question regarding worker caching
I have a worker that acts as a rest api to CRUD blog posts, the worker uses KV as the database. When reading a blog post (the main thing I'm focused on improving), the worker simply returns raw html thats stored in KV. The worker is fairly lightweight, when doing a read, it does nothing more than a KV read and returning the result.
I have 2 issues that im trying to resolve:
(1) If I wait a minute or 2, the first request to the worker always takes over 500ms~ (instead of 40~ms). I dont know for sure what the cause of this is. If I refresh a few times, it speeds up. But then seems to just reset after a bit.
(2) I am exploring the suggestion that using the cache api would reduce KV reads and make it faster, but im having trouble implementing it and im not sure if it would even work in my use case, i.e if the user edits/deletes their blog post, I need to be able to reflect that in the cache. I also dont understand if Im supposed to set
Cache-Control
header on the cached response, if i do set that it removes my ability to edit/delete posts, unless I just set it low enough that it wouldnt give any benefit
Attached is a picture from chrome of a request to the worker. Thank you 🙂1 Reply
so an uncached kv read takes over 500ms? that seems crazily slow