Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Added "How to Use a Custom Version Strategy for Assets" #7141

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

Merged
merged 12 commits into from
Dec 12, 2016
Prev Previous commit
Next Next commit
Minor rewords and fixes
  • Loading branch information
javiereguiluz committed Nov 15, 2016
commit 482fda5659c59bce933eb9462e0bbf0221cd0887
17 changes: 9 additions & 8 deletions 17 frontend/custom_version_strategy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ How to Use a Custom Version Strategy for Assets
The Asset component was introduced in Symfony 2.7.

Asset versioning is a technique that improves the performance of web
applications by adding a version identifier to the URL of your static assets
(CSS, JavaScript, images, etc.) When the content of the asset changes, the
identifier changes and the browser is forced to download it again instead of
using the cached version.
applications by adding a version identifier to the URL of the static assets
(CSS, JavaScript, images, etc.) When the content of the asset changes, its
identifier is also modified to force the browser download it again instead of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] the browser to download it [...]

reusing the cached asset.

Symfony supports the basic asset versioning thanks to the
Symfony supports asset versioning thanks to the
:ref:`version <reference-framework-assets-version>` and
:ref:`version_format <reference-framework-assets-version-format>` configuration
options. If your application requires a more advanced versioning, you can create
your own version strategy.
options. If your application requires a more advanced versioning, such as
generating the version dynamically based on some external information, you can
create your own version strategy.

Creating your Own Asset Version Strategy
----------------------------------------
Expand All @@ -39,7 +40,7 @@ Implement VersionStrategyInterface
Asset version strategies are PHP classes that implement the
:class:`Symfony\\Component\\Asset\\VersionStrategy\\VersionStrategyInterface`.
In this example, the constructor of the class takes as arguments the path to
the manifest file generated by gulp-buster and the format of the generated
the manifest file generated by `gulp-buster`_ and the format of the generated
version string::

// src/AppBundle/Asset/VersionStrategy/GulpBusterVersionStrategy.php
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.