LoginSignup
34
14

More than 5 years have passed since last update.

GitHubのREADME上の画像キャッシュはPURGEリクエストで破棄させられる

Posted at

GitHubのREADMEの画像,とくにビルドステータス・カバレッジ・コードクオリティ関連のものが長期間キャッシュされてしまって困ったことは無いでしょうか?

img

RFCで標準化されていないようですが,PURGEというHTTPメソッドでリクエストを送るとそれを破棄させることができるようです。

curlコマンドの-Xオプションを使用
mpyw@localhost:~$ curl -X PURGE https://camo.githubusercontent.com/f3bff8cae56a5e157f25ed6bf0a76aa610832897/68747470733a2f2f7472617669732d63692e6f72672f6d7079772f657863657065722e7376673f6272616e63683d6d6173746572
{"status": "ok", "id": "397-1491501868-70734"}

いちいち1個1個インスペクタで調べるのも面倒なので,スクレイピングして自動でリクエストを送るシェルスクリプトを書きました。

mpyw/hub-purge: Clear GitHub image caches on README

使用例
mpyw@localhost:~$ hub-purge mpyw/co mpyw/cowitter mpyw/php-hyper-builtin-server mpyw/exceper 
Fetching: https://github.com/mpyw/co
Fetching: https://github.com/mpyw/cowitter
Fetching: https://github.com/mpyw/php-hyper-builtin-server
Fetching: https://github.com/mpyw/exceper
Purging: https://camo.githubusercontent.com/aee60d37fae05af268e89fec187311cbfcdcc2ea/68747470733a2f2f7472617669732d63692e6f72672f6d7079772f7068702d68797065722d6275696c74696e2d7365727665722e7376673f6272616e63683d6d6173746572
Purging: https://camo.githubusercontent.com/730f7deb762c1334f59cadb72111262f74a718a4/68747470733a2f2f7472617669732d63692e6f72672f6d7079772f636f2e7376673f6272616e63683d6d6173746572
Purging: https://camo.githubusercontent.com/f3bff8cae56a5e157f25ed6bf0a76aa610832897/68747470733a2f2f7472617669732d63692e6f72672f6d7079772f657863657065722e7376673f6272616e63683d6d6173746572
Purging: https://camo.githubusercontent.com/e5e3d68e65bd6c9922e40dad8003f4aeb49ffd0e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d7079772f7068702d68797065722d6275696c74696e2d7365727665722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572
Purging: https://camo.githubusercontent.com/f7e4d8bb540f5418242df6cb23da2c69bea31d30/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d7079772f636f7769747465722f6261646765732f6275696c642e706e673f623d6d6173746572
Purging: https://camo.githubusercontent.com/11c32d7a00c83ff76a57984bcad1bd6772020ee1/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d7079772f657863657065722f62616467652e7376673f6272616e63683d6d6173746572
Purging: https://camo.githubusercontent.com/8e895d8ad6fe3403d68859a8fec73d81b09f9f83/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d7079772f636f2f62616467652e7376673f6272616e63683d6d6173746572
Purging: https://camo.githubusercontent.com/5ef75697c52c3bebb46a10c00a17a527cc6c03e0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d7079772f636f7769747465722f6261646765732f636f7665726167652e706e673f623d6d6173746572
Purging: https://camo.githubusercontent.com/12c40f97da07541cc6e3561bb7312872c1255bce/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d7079772f636f7769747465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572
Purging: https://camo.githubusercontent.com/9adea0c1258932734316eac1137cad998da262e3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d7079772f657863657065722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572
Purging: https://camo.githubusercontent.com/91b090d2115278ccbcb4250a8b636470515a9c02/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d7079772f636f2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572

mpyw@localhost:~$

きっと便利。

34
14
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
34
14