{"action":"created","issue":{"url":"https://api.github.com/repos/opencart/opencart/issues/3083","labels_url":"https://api.github.com/repos/opencart/opencart/issues/3083/labels{/name}","comments_url":"https://api.github.com/repos/opencart/opencart/issues/3083/comments","events_url":"https://api.github.com/repos/opencart/opencart/issues/3083/events","html_url":"https://github.com/opencart/opencart/issues/3083","id":85571873,"number":3083,"title":"$this->document->addTimestamp()","user":{"login":"dhaupin","id":6352930,"avatar_url":"https://avatars.githubusercontent.com/u/6352930?v=3","gravatar_id":"","url":"https://api.github.com/users/dhaupin","html_url":"https://github.com/dhaupin","followers_url":"https://api.github.com/users/dhaupin/followers","following_url":"https://api.github.com/users/dhaupin/following{/other_user}","gists_url":"https://api.github.com/users/dhaupin/gists{/gist_id}","starred_url":"https://api.github.com/users/dhaupin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhaupin/subscriptions","organizations_url":"https://api.github.com/users/dhaupin/orgs","repos_url":"https://api.github.com/users/dhaupin/repos","events_url":"https://api.github.com/users/dhaupin/events{/privacy}","received_events_url":"https://api.github.com/users/dhaupin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-05T16:18:46Z","updated_at":"2015-06-13T18:58:04Z","closed_at":"2015-06-13T18:58:04Z","body":"OC is missing cache buster abilities. Since TONS of folks now use Cloudflare, and local browser caching is more brute, updating assets turns into a tedious \"clear multiple caches\" timewaste. This would be a great addition to core. It appends the timestamp string to the end of local assets defined via the document library:\r\n\r\n\tpublic function addTimestamp($src) {\r\n\t\t$base = str_replace('system', '', DIR_SYSTEM);\r\n\t\t$http = 'http://' . $_SERVER['SERVER_NAME'] . '/';\r\n\t\t$https = 'https://' . $_SERVER['SERVER_NAME'] . '/';\r\n\t\t$httpr = '//' . $_SERVER['SERVER_NAME'] . '/';\r\n\r\n\t\t$file = realpath(str_replace(array($http, $https, $httpr), $base, $src));\r\n\r\n\t\tif (file_exists($file)) {\r\n\t\t\treturn $src . '?v=' . filemtime($file);\r\n\t\t}\r\n\t\treturn $src;\r\n\t}\r\n\r\nExample use situation, all scripts inserted via document class are now timestamped:\r\n\r\n\t$this->scripts[md5($script)] = $this->addTimestamp($script);\r\n\r\nExample use situation, your random mod can inject a timestamped image (or anything):\r\n\r\n\t$data['my_asset_src'] = $this->document->addTimestamp('catalog/view/theme/default/image/my_asset.jpg');\r\n\r\nSorry if this is not the proper channel to share this!"},"comment":{"url":"https://api.github.com/repos/opencart/opencart/issues/comments/111740531","html_url":"https://github.com/opencart/opencart/issues/3083#issuecomment-111740531","issue_url":"https://api.github.com/repos/opencart/opencart/issues/3083","id":111740531,"user":{"login":"danielkerr","id":5079756,"avatar_url":"https://avatars.githubusercontent.com/u/5079756?v=3","gravatar_id":"","url":"https://api.github.com/users/danielkerr","html_url":"https://github.com/danielkerr","followers_url":"https://api.github.com/users/danielkerr/followers","following_url":"https://api.github.com/users/danielkerr/following{/other_user}","gists_url":"https://api.github.com/users/danielkerr/gists{/gist_id}","starred_url":"https://api.github.com/users/danielkerr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielkerr/subscriptions","organizations_url":"https://api.github.com/users/danielkerr/orgs","repos_url":"https://api.github.com/users/danielkerr/repos","events_url":"https://api.github.com/users/danielkerr/events{/privacy}","received_events_url":"https://api.github.com/users/danielkerr/received_events","type":"User","site_admin":false},"created_at":"2015-06-13T18:58:04Z","updated_at":"2015-06-13T18:58:04Z","body":"not required"}}