Skip to content
Snippets Groups Projects
Commit 67e809a6 authored by Tim Steiner's avatar Tim Steiner
Browse files

[gh-221] Merging from testing into staging

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@1059 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent 44a8be18
No related branches found
No related tags found
No related merge requests found
......@@ -39,3 +39,32 @@ function unl_varnish_purge_submit($form, &$form_state) {
_varnish_terminal_run("purge.url $path");
drupal_set_message("Varnish purged paths matching $path.", 'status');
}
/**
* Implements hook_file_insert().
*/
function unl_varnish_file_insert($file) {
_unl_varnish_purge_file($file);
}
/**
* Implements hook_file_update().
*/
function unl_varnish_file_update($file) {
_unl_varnish_purge_file($file);
}
/**
* Instructs varnish to purge the given file from its cache.
* @param stdClass $file as provided by hook_file_[insert,update]
*/
function _unl_varnish_purge_file($file) {
$url = parse_url(file_create_url($file->uri));
$host = $url['host'];
$path = $url['path'];
$command = "purge req.http.host == $host && req.url ~ ^$path\$";
_varnish_terminal_run($command);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment