{"id":28754250,"url":"https://github.com/zeroasterisk/cdnmd5","last_synced_at":"2025-06-17T01:08:12.714Z","repository":{"id":9106913,"uuid":"10887916","full_name":"zeroasterisk/cdnmd5","owner":"zeroasterisk","description":"CDN Assets + md5 hash as part of the filename = always unique URL.  A CakePHP Plugin/Lib to facilitate (for JS, CSS, Images, etc)","archived":false,"fork":false,"pushed_at":"2022-02-28T21:15:30.000Z","size":200,"stargazers_count":1,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-04-01T09:41:42.619Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"google/codesearch","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zeroasterisk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-23T16:33:01.000Z","updated_at":"2015-05-22T10:13:17.000Z","dependencies_parsed_at":"2022-08-07T05:00:32.133Z","dependency_job_id":null,"html_url":"https://github.com/zeroasterisk/cdnmd5","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/zeroasterisk/cdnmd5","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroasterisk%2Fcdnmd5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroasterisk%2Fcdnmd5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroasterisk%2Fcdnmd5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroasterisk%2Fcdnmd5/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeroasterisk","download_url":"https://codeload.github.com/zeroasterisk/cdnmd5/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroasterisk%2Fcdnmd5/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260269462,"owners_count":22983647,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-17T01:08:11.671Z","updated_at":"2025-06-17T01:08:12.696Z","avatar_url":"https://github.com/zeroasterisk.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"CDNMD5\n==========\n\nA helful library to allow you to create a unique version of every asset on\na CDN, but renaming the filename (on the CDN) to the md5sum hash of the file.\n\nThis means you always defeate browser cache when the file is changed, but also\nalways utilize browser cache when the file remains unchanged...\n\nNo more query string timestamps.\n\nJustification\n---------------\n\nFile Assets need to be stored on a CDN\nbut each \"specific\" version of the files need to be accessed,\nand sometimes we are going forward in time, and backward in time,\nall versions need to be available, uniquely\n\nAs such, the basic plan is:\n\non file creation/editing:\nbefore you use this library, create the file...\nthen use this library to:\n\n1. make a md5sum of the file ($md5hash)\n2. store the md5sum of the file in a config file (commited to git)\n3. make a copy of the file renamed to `\"{$filename}_{$md5hash}.{$ext}\"`\n4. transfer the renamed copy to the CDN\n\nAt the time of rendering the file:\n\n`Cdnmd5::url($filename) ==\u003e http://domain/filename_md5hash.ext`\n\nThis function looks up the md5hash stored in the config file and returns\nthe URL to the CDN for the file...\n\nIf we are in development mode: `Configure::read('Cdnmd5.disabled') == true`\n\nOR\n\nIf that md5hash doesn't exist for some reason (or is empty) we try to just\nload the \"real\" file from the local repository.\n\nLimitations:\n---------------\n\n**Filenames must be unique**, all path data is stripped when determining the\nmd5hash for a file and when transfering files to the CDN.  This means if you\nhave 'webroot/css/main.css' and 'webroot/plugin/main.css' that they will walk\non top of each other and you'll never get what you want.\n\nI highly recommend you aggregate your assets into one or two files per type,\nbefore you consider the **cdnmd5** processing.\n\nSuggestions\n\n* https://github.com/markstory/asset_compress (cakephp toolkit for all assets)\n* https://developers.google.com/closure/ (slow, java, but best compression and good parser warnings)\n* https://github.com/mishoo/UglifyJS2 (fast JS aggregation/minification)\n\nNote: This library only works with one CDN at a time (for now).\n\n\n\nRequirements:\n-------------------\n\n1. php5\n2. php5-curl\n3. CakePHP (could be decoupled with a little bit of work)\n\n(CakePHP 1.3, CakePHP 2x versions available, switch branches)\n\nNOTE: submodules added for API Libs, inside plugin/vendors\n\ngit://github.com/zeroasterisk/php-opencloud.git -\u003e [plugindir]/vendors/php-opencloud\n\nInstallation:\n-------------------\n\nPut the plugin into the correct place in the CakePHP app:\n\n**CakePHP 1.3**\n\n```\ncd repo\ngit submodule add git://github.com/zeroasterisk/cdnmd5 app/plugins/cdnmd5\ncd app/plugins/cdnmd5\ngit checkout 1.3\ncd ../../..\ngit submodule update --init --recursive\ncp app/plugins/cdnmd5/config/cdnmd5.example.php app/config/cdnmd5.php\nvim app/config/cdnmd5.php\n```\n\nUsage:\n-----------------\n\nAfter you create your CDNable assets (AssetCompress, Closure, Uglify, CssMin, etc)\n\n```\nApp::Import('Lib', 'Cdnmd5.Cdnmd5');\nCdnmd5::process(APP . $fullPathToFile);\n```\n\nAnd how to render it in your Views\n\n```\nApp::Import('Lib', 'Cdnmd5.Cdnmd5');\n$this-\u003eHtml-\u003escript(Cdnmd5::url($webrootRelativePathTofile));\n```\n\nOr with the simple helper:\n\n```\n$this-\u003eCdnmd5-\u003escript($webrootRelativePathTofile);\n```\n\nAbout / License\n----------------\n\nAuthor: Alan Blount \u003calan@zeroasterisk.com\u003e\n\nLicense: MIT (see https://github.com/zeroasterisk/cdnmd5/LICENSE.txt)\n\n(pull requests encouraged)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeroasterisk%2Fcdnmd5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeroasterisk%2Fcdnmd5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeroasterisk%2Fcdnmd5/lists"}