承接 purplespider/silverstripe-assets-cachebusting 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

purplespider/silverstripe-assets-cachebusting

最新稳定版本:2.0.0

Composer 安装命令:

composer require purplespider/silverstripe-assets-cachebusting

包简介

Automatic cache busting for SilverStripe assets by appending file hash to URLs

README 文档

README

Automatic cache busting for SilverStripe assets by appending file content hash to URLs.

Overview

This module adds automatic cache busting to all asset URLs in SilverStripe by appending a unique parameter based on the file's content hash. This allows you to set aggressive browser cache headers (long expiry times) while ensuring browsers and CDNs (like Cloudflare) fetch updated files when they change.

Solves a common problem: When a CMS user replaces an asset with a new file using the same filename, CDNs and browsers can serve the old cached version for hours or days. This module ensures the URL changes automatically when the file content changes, forcing immediate updates.

Before:

/assets/images/logo.png

After:

/assets/images/logo.png?m=a1b2c3d4e5

When the file content changes, the hash automatically updates, forcing browsers to fetch the new version.

Version Compatibility

Module Version SilverStripe Version Assets Version
1.x 5.x 2.x
2.x 6.x 3.x

For SilverStripe 5: Use version 1.x

composer require purplespider/silverstripe-assets-cachebusting:^1.0

For SilverStripe 6: Use version 2.x (current)

composer require purplespider/silverstripe-assets-cachebusting:^2.0

Installation

Install via Composer (will install the version compatible with your SilverStripe installation):

composer require purplespider/silverstripe-assets-cachebusting

Then run dev/build:

SilverStripe 5:

vendor/silverstripe/framework/cli-script.php dev/build flush=1

SilverStripe 6:

vendor/bin/sake db:build --flush

Configuration

Cache busting is enabled by default. To disable it, add this to your config:

SilverStripe\Assets\File:
  enable_cache_busting: false

How It Works

The module automatically appends a unique hash parameter to all asset URLs. The hash is based on the file's content, so it changes whenever a file is replaced - even if the filename stays the same.

This works everywhere: file links, images in WYSIWYG content, template references, resized images, and more. When a CMS user replaces an asset, Cloudflare and other CDNs immediately serve the new version.

Credits

Based on SilverStripe Framework PR #2402 by @patbolo.

License

BSD-3-Clause. See LICENSE for details.

Contributing

Contributions are welcome! Please open an issue or pull request on GitHub.

统计信息

  • 总下载量: 30
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-01-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固