Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Created June 5, 2012 05:26
Show Gist options
  • Save wokamoto/2872849 to your computer and use it in GitHub Desktop.
Save wokamoto/2872849 to your computer and use it in GitHub Desktop.
Nginx Cache Controller ver.1.1.2+ で、標準以外の URL キャッシュを削除する方法
<?php
add_filter('nginxchampuru_get_cache', 'nginxchampuru_get_cache', 10, 2);
function nginxchampuru_get_cache($key, $url = null) {
global $nginxchampuru;
if (!$url) {
$url = $nginxchampuru->get_the_url();
}
$keys = array(
$key,
$nginxchampuru->get_cache_key($url.'@ktai'),
$nginxchampuru->get_cache_key($url.'@smartphone'),
$nginxchampuru->get_cache_key($url.'@smartphone.off'),
);
if ($key !== $nginxchampuru->get_cache_key($url)) {
$keys[] = $nginxchampuru->get_cache_key($url);
}
return $nginxchampuru->get_cache_file($keys);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment