{"id":20770586,"url":"https://github.com/codemonauts/craft-asset-autoversioning","last_synced_at":"2025-04-30T13:51:10.062Z","repository":{"id":33790848,"uuid":"143162956","full_name":"codemonauts/craft-asset-autoversioning","owner":"codemonauts","description":"A Twig extension for Craft CMS that helps you cache-bust your assets","archived":false,"fork":false,"pushed_at":"2022-05-04T06:33:49.000Z","size":47,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-21T09:52:43.816Z","etag":null,"topics":["cache-bust","caching","cms","craft","craftcms","plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codemonauts.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-01T13:54:07.000Z","updated_at":"2023-12-11T02:29:58.000Z","dependencies_parsed_at":"2022-07-22T14:17:30.017Z","dependency_job_id":null,"html_url":"https://github.com/codemonauts/craft-asset-autoversioning","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonauts%2Fcraft-asset-autoversioning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonauts%2Fcraft-asset-autoversioning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonauts%2Fcraft-asset-autoversioning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonauts%2Fcraft-asset-autoversioning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemonauts","download_url":"https://codeload.github.com/codemonauts/craft-asset-autoversioning/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251714930,"owners_count":21631806,"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":["cache-bust","caching","cms","craft","craftcms","plugin"],"created_at":"2024-11-17T12:10:41.694Z","updated_at":"2025-04-30T13:51:09.985Z","avatar_url":"https://github.com/codemonauts.png","language":"PHP","readme":"# Assets Autoversioning plugin for Craft CMS\n\n![Icon](resources/autoversioning.png)\n\nA really basic Twig extension for CraftCMS that helps you cache-bust your assets.\n\n## Background\n\nTo force the browser to download the new asset file after a update, the plugin allows you to add a Twig function, which adds the build number or the filemtime to the filename.\n\n## Requirements\n\n * Craft CMS \u003e= 4.0.0\n\n## Installation\n### Project\n\nOpen your terminal and go to your Craft project:\n\n``` shell\ncd /path/to/project\ncomposer require codemonauts/craft-asset-autoversioning\n./craft install/plugin craft3-assets-autoversioning\n```\n\n### CI/CD Pipeine\nThe build number which gets added to the asset URL is read from a file called `build.txt` which must exist in your project folder. Use for example something like this in your deployment script (Example is for CodeShip):\n\n``` shell\necho -n \"${CI_BUILD_NUMBER}\" \u003e build.txt\n```\n\nIf the file doesn't exists, the filemtime of the asset is used.\n\n### Webserver\n\nBecause the clients will from now on start to request files like `/css/styles.12345678.css` we need to tell the webserver how to rewrite these URLs so that the original `/css/styles.css` will get served.\n\n**Apache** \n\n``` apacheconfig\n\u003cIfModule mod_rewrite.c\u003e\n    RewriteEngine On\n    RewriteCond %{REQUEST_FILENAME} !-f\n    RewriteRule ^(.*?\\/)*?([a-z\\.\\-]+)(\\d+)\\.(bmp|css|cur|gif|ico|jpe?g|js|png|svgz?|webp|webmanifest)$ $1$2$4 [L]\n\u003c/IfModule\u003e\n```\n\n**NGINX**\n\n``` nginx\nlocation ~* (.+)\\.(?:\\d+)\\.(js|css|png|jpg|jpeg|gif|webp)$ {\n  try_files $uri $1.$2;\n}\n```\n\n## Usage\n\nUse the new Twig function ```versioning()``` in your template. For example in pug:\n\n``` twig\n\u003clink rel=\"stylesheet\" href=\"{{ versioning('/css/styles.css')}}\"\u003e\n``` \n\nwill result in something like this:\n\n``` html\n\u003clink rel=\"stylesheet\" href=\"/css/styles.12345678.css\"\u003e\n```\n\nWith ❤ by [codemonauts](https://codemonauts.com)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonauts%2Fcraft-asset-autoversioning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemonauts%2Fcraft-asset-autoversioning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonauts%2Fcraft-asset-autoversioning/lists"}