Open
Description
ref https://fswiki.osdn.jp/cgi-bin/wiki.cgi?page=BugTrack%2Dplugin%2F219
動機
- freestylewikiをサーバで動作させていると、Perlによるアプリケーション処理が毎回走るので遅い
- CDN(CloudFlare)でキャッシュさせようとしても、以下のように
Cache_Control => 'no-cache'
が入っているのでうまくキャッシュできない
https://github.com/hangingman/fswiki/search?q=no-cache
Lines 287 to 295 in fb668d5
Cache_Control => 'no-cache'
の場合のCloudFlareの挙動
no-cache — Indicates the response cannot be used to satisfy a subsequent request without successful validation on the origin server. This allows an origin server to prevent a cache from using the origin to satisfy a request without contacting it, even by caches that have been configured to send stale responses.
検討
下記のような仕様を考えた
- fswikiは通常はリクエストをすべてキャッシュさせる
- ただし、ページの参照レベルが全員に公開の場合のみ
- キャッシュ済みのページへのリクエストはcloudflare上のキャッシュを返却する
- wikiのページが更新されたときにcloudflare上のキャッシュをpurgeする
fswikiの更新契機は、すべてsave_page
が実行されたときなのでhookはそのタイミングで実行される
CloudFlareへのキャッシュ用ヘッダを返す処理と、wikiのページが更新されたときにcloudflare上のキャッシュをpurgeする処理の2つをpluginの中で書くイメージ。