peterz
CDCloudflare Developers
•Created by peterz on 12/29/2024 in #workers-help
Vitest and cache
oh nevermind, I just found the config place in vitest 🙂
21 replies
CDCloudflare Developers
•Created by peterz on 12/29/2024 in #workers-help
Vitest and cache
now I'm a bit confused about secrets. What's the proper way of testing a
SELF.fetch(request)
and having some secrets as environment variables?21 replies
CDCloudflare Developers
•Created by peterz on 12/29/2024 in #workers-help
Vitest and cache
just to add another detail, as I said previously, the original worker behaves as expected. The difference is that the origin responses had the cache-control header, and my mock responses didn't.
21 replies
CDCloudflare Developers
•Created by peterz on 12/29/2024 in #workers-help
Vitest and cache
OMG 🤦
I just tested, of course, it makes sense...
Thank you very much @James!!!
BTW, have a great new year!
21 replies
CDCloudflare Developers
•Created by peterz on 12/29/2024 in #workers-help
Vitest and cache
I wasn't using it to check, it was just to make the test fail. I was checking in the logs. I created this minimal example (from here) where we can see both in the logs and the fail test.
Worker:
Tests:
21 replies
CDCloudflare Developers
•Created by peterz on 12/29/2024 in #workers-help
Vitest and cache
I changed the implementation and it still doesn't work. Now I'm testing with two sequential requests to same url, and both are hitting the origin... tried both with
SELF.fetch
and worker.fetch
. No luck.
21 replies
CDCloudflare Developers
•Created by peterz on 12/29/2024 in #workers-help
Vitest and cache
ok, thank you very much @James!
21 replies
CDCloudflare Developers
•Created by peterz on 12/29/2024 in #workers-help
Vitest and cache
Another thing then, where can I find the "best practices" currently for testing workers?
21 replies
CDCloudflare Developers
•Created by peterz on 12/29/2024 in #workers-help
Vitest and cache
Thank you @James, there are indeed some differences in your example, I'll take a closer look. However, putting aside if I may the request part, only the
cache
is failing. This fails on the expect(cachedResponse2).toBeDefined();
line.
21 replies
CDCloudflare Developers
•Created by peterz on 4/10/2023 in #pages-help
Cache Purge
Ok, got it, thanks a lot for clarifying 👌
19 replies
CDCloudflare Developers
•Created by peterz on 4/10/2023 in #pages-help
Cache Purge
Ok. So, for this scenario, I want to cache my responses, but I also want to be able to purge the cache at any time. I've seen that re-deploying doesn't purge the cache. How can I do this?
19 replies
CDCloudflare Developers
•Created by peterz on 4/10/2023 in #pages-help
Cache Purge
But I don't have any of that configured. I just created a Pages app. If my app responds with cache headers, CF caches it and responds with cache version (I can see both the cache status HIT and if I change content on the CMS the response doesn't change). If my app doesn't respond with cache headers, CF doesn't cache at all (I can confirm it by making changes on the CMS).
19 replies
CDCloudflare Developers
•Created by peterz on 4/10/2023 in #pages-help
Cache Purge
I guess yes... if it's caching there when I send the cache headers
19 replies
CDCloudflare Developers
•Created by peterz on 4/10/2023 in #pages-help
Cache Purge
If I don't send the cache headers, CF doesn't cache at all.
How can I purge cache?
19 replies
CDCloudflare Developers
•Created by peterz on 4/10/2023 in #pages-help
Cache Purge
ok, thanks. I'm gonna make a few more tests 👍
19 replies
CDCloudflare Developers
•Created by peterz on 4/10/2023 in #pages-help
Cache Purge
hmm... does it mean CF doesn't return the
cf-cache-status: HIT
and Cache-Control: ...
headers in that case, but still responds with a cached version? Then the browser doesn't cache anything too...19 replies
CDCloudflare Developers
•Created by peterz on 4/10/2023 in #pages-help
Cache Purge
But when I wasn't sending those headers, it wasn't caching at all 😕
19 replies
CDCloudflare Developers
•Created by peterz on 4/10/2023 in #pages-help
Cache Purge
I'm not, I don't have a custom domain (yet).
I was expecting that too, but it isn't...
May it be related to the fact that I'm sending cache headers on the responses?
19 replies