To cache MediaWiki pages on the Edge, I set up two Cache Rules as below:
http.host eq "wiki.example.com" and ( starts_with(http.request.uri.path, "/wiki/Special:") or ((http.cookie contains "example_com_wikiUserID") and (http.cookie contains "example_com_wiki_session") and (http.cookie contains "example_com_wikiUserName")) )
wikiUserName are present, the request will be recognized as logged in user and get bypassed.
Eligible for Cache:
http.host eq "wiki.example.com" and ( http.request.uri.path eq "/load.php" or ( (starts_with(http.request.uri.path, "/wiki/") or starts_with(http.request.uri.path, "/history/")) and (not http.request.uri contains "?")) )
Then I set up to cache these pages.
When a page is eligible for cache, the server will cooperatively send its
cache-control: s-maxage=18000, must-revalidate, max-age=0
Now say I’m new to the site and I want to login. I went through
/wiki/Special:Login where it takes me to a ride of requests and assigned me
I took those cookies and went ahead to visit
Bummer. The site shows that I’m not logged in because
I go to Cloudflare Dashboard to purge everything. Now it is back to normal.
Moreover, when I logged out, and the server clears the cookies for me, I’m still receiving
unless I visit the page in the incognito window once.