Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep timestamp in store config to make it independent from general cache #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/code/community/Aoe/JsCssTstamp/Model/Observer.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ public function clean_media_cache_after()
$dbStorage->getDirectoryModel()
->deleteDirectory('js')
->deleteDirectory('css');

// clean timestamp from config
Mage::getConfig()->saveConfig(Aoe_JsCssTstamp_Model_Package::XML_PATH_CACHEKEY, null);
}
}
11 changes: 9 additions & 2 deletions app/code/community/Aoe/JsCssTstamp/Model/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Aoe_DesignFallback_Model_Design_Package extends Mage_Core_Model_Design_Pac
*/
class Aoe_JsCssTstamp_Model_Package extends Aoe_DesignFallback_Model_Design_Package
{
const XML_PATH_CACHEKEY = 'aoe/jscsststamp/aoe_jscsststamp_versionkey';

const CACHEKEY = 'aoe_jscsststamp_versionkey';

protected $cssProtocolRelativeUris;
Expand Down Expand Up @@ -245,15 +247,20 @@ protected function generateMergedUrl($type, array $files, $targetDir, $targetFil

/**
* Get a cached timestamp as version key
* If none then try get from config
*
* @return int timestamp
*/
protected function getVersionKey()
{
$timestamp = Mage::app()->loadCache(self::CACHEKEY);
if (empty($timestamp)) {
$timestamp = time();
Mage::app()->saveCache($timestamp, self::CACHEKEY, array(), null);
$timestamp = Mage::getStoreConfig(self::XML_PATH_CACHEKEY);
if (empty($timestamp)) {
$timestamp = time();
Mage::getConfig()->saveConfig(self::XML_PATH_CACHEKEY, $timestamp);
Mage::app()->saveCache($timestamp, self::CACHEKEY, array(), null);
}
}

return $timestamp;
Expand Down