Skip to content

Commit

Permalink
Merge pull request #57 from stephenmcm/feature-cacheKey
Browse files Browse the repository at this point in the history
Fix getCacheKey() to treat urls like SS_HTTPRequest::setUrl()
  • Loading branch information
Damian Mooyman authored Mar 19, 2017
2 parents a90a2ef + e3c6613 commit 32dd61c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions code/DynamicCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,18 @@ protected function getCacheKey($url)
$fragments = array();

// Segment by protocol (always)
$fragments[] = Director::protocol();
$fragments['protocol'] = Director::protocol();

// Segment by hostname if necessary
if (self::config()->segmentHostname) {
$fragments[] = $_SERVER['HTTP_HOST'];
$fragments['HTTP_HOST'] = $_SERVER['HTTP_HOST'];
}

// Segment by url
$fragments[] = trim($url, '/');
// Clean up url to match SS_HTTPRequest::setUrl() interpretation
$fragments['url'] = preg_replace('|/+|', '/', $url);

// Extend
$this->extend('updateCacheKeyFragments', $fragments);
$this->extend('updateCacheKeyFragments', $fragments, $url);

return "DynamicCache_" . md5(implode('|', array_map('md5', $fragments)));
}
Expand Down

0 comments on commit 32dd61c

Please sign in to comment.