LoginSignup
1
1

More than 3 years have passed since last update.

ShinobiLayer: CDNキャッシュを明示的にPurgeする方法(Customer Portal編)

Last updated at Posted at 2015-03-08

はじめに

基本的にSoftLayerのCDN(中身はEdgeCastのCDN)のキャッシュ制御は、Origin Server側で実施する必要があります。

(参考)
What are some example configuration changes for Origin Pull on an Apache Web Server?
http://knowledgelayer.softlayer.com/faq/what-are-some-example-configuration-changes-origin-pull-apache-web-server

とはいっても、Originサーバーでコンテンツを置き換えた時に、即時にキャッシュ内容を反映させたい時などには、やはり明示的に既存のCDNキャッシュをPurgeさせ、新しいコンテンツをキャッシュさせたいものです。この記事では、カスタマーポータルからCDNキャッシュをPurgeさせるための方法を紹介したいと思います。

Customer PortalでのPurge画面

Storage -> CDN -> "CDN Account ID"からCache Managementのタブを選択すると、以下のような画面が出てきます。ここに該当のURLを入力して、Purgeボタンを押せば完了です。
CDN_CapturedImage.jpg

パージのルール

このGUI画面によると、
FTPの場合: http://xxxxx.http.cdn.softlayer.net/00xxxxx/
HTTPの場合: http://xxxxx.http.cdn.softlayer.net/80xxxxx/
と紹介されているので、このURLをそのまま入力すればいいのね、簡単簡単・・・と思いきや、幾つか罠が潜んでいます。

結論からいうと、以下のルールに従うようです。

  • サブディレクトリまで含めて全てのキャッシュを削除したい時は、最後に"/*"を付ける。
http://xxxxx.http.cdn.softlayer.net/80xxxxx/*
http://xxxxx.http.cdn.softlayer.net/80xxxxx/origin.mysl01.com/*
http://xxxxx.http.cdn.softlayer.net/80xxxxx/origin.mysl01.com/cdn/*
  • 特定のファイルだけを削除したい時は、当然直接指定する。
http://xxxxx.http.cdn.softlayer.net/80xxxxx/origin.mysl01.com/cdn/index.html
http://xxxxx.http.cdn.softlayer.net/80xxxxx/origin.mysl01.com/cdn/images/ninja.png
  • 特定のディレクトリ直下のファイルのみ削除したい時は、ファイル名にワイルドカードを指定する。
http://xxxxx.http.cdn.softlayer.net/80xxxxx/origin.mysl01.com/cdn/*.*
http://xxxxx.http.cdn.softlayer.net/80xxxxx/origin.mysl01.com/cdn/images/*.jpg

以下、NGケース

  • いくらワイルドカードが効くからといって、さすがに80xxxxxまでを省略して書くのはNG。
http://xxxxx.http.cdn.softlayer.net/*
  • ディレクトリ配下の指定になっていないので何も消えない。ディレクトリ配下全てを対象にしたいならば、/*を付けるべき。
http://xxxxx.http.cdn.softlayer.net/80xxxxx/
http://xxxxx.http.cdn.softlayer.net/80xxxxx/origin.mysl01.com/cdn/
  • ディレクトリに対してワイルドカードは効かない。
http://xxxxx.http.cdn.softlayer.net/80xxxxx/origin*
http://xxxxx.http.cdn.softlayer.net/80xxxxx/*/cdn/*

キャッシュのPurgeにかかる時間について

Customer Portal上での注意書きには、キャッシュパージに要する時間は3-5分程度と書かれてありますが、私が試してみた感じでは、コンテンツが少ないからか、多くのケースで2分程度で済んでいました。

おわりに

slコマンド編はこちらで紹介しています。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1