Plugin Contributor
iSaumya
(@isaumya)
Hi,
What you are looking for are simply not possible. First of all whenever there is a cookie on a page (i.e. set-cookie in the response header), Cloudflare will simply bypass that page from cache and will be served by the origin server.
This is because based on the cookie value many dynamic data might be shown on the page which needs to be generated by the server. Also if CF starts caching all possible outcome of a page in the cache, not only their server will outrun of space to cache all these multiple variation of pages which will have much lower traffic as those pages are only being showed to people with that specific cookie. Also cache invalidation would be another nightmare which honestly makes no business, financial or economic sense.
So, whenever CF sees a cookie on a page it simply bypass cache for that page and it is always served by the origin server.
Thread Starter
eddr
(@eddr)
OK thanks, but what if you define only two options for a specific cookie?
I think it makes sense
Plugin Contributor
iSaumya
(@isaumya)
Have you read my reply above? CF doesn’t cache any pages when there is a custom cookie present.
Thread Starter
eddr
(@eddr)
Thanks for the reply and sorry for the late response
I understand what you say, but I’m asking further. I thought a worker script can change it. Also wrote one which seems to work (basically), but maybe I’m missing something.
Plugin Contributor
iSaumya
(@isaumya)
Even if you write a custom worker you cannot change the default CF cache behavior. CF will always bypass caching for pages with custom cookies in them. The reason has been explained above.