evheniy / html5-cache-bundle
HTML5CacheBundle可以向您的应用程序添加HTML5应用程序缓存的特性。
1.5.0
2018-04-09 19:06 UTC
Requires
- php: >=7.1
- symfony/config: ~3.0|~4.0
- symfony/console: ~3.0|~4.0
- symfony/dependency-injection: ~3.0|~4.0
- symfony/finder: ~3.0|~4.0
- symfony/framework-bundle: ~3.0|~4.0
- symfony/http-kernel: ~3.0|~4.0
- symfony/templating: ~3.0|~4.0
- symfony/twig-bridge: ~3.0|~4.0
- twig/twig: ^2.4
Requires (Dev)
- phpunit/phpunit: ^7.1
- satooshi/php-coveralls: ~2.0
This package is not auto-updated.
Last update: 2024-09-24 21:44:44 UTC
README
此捆绑包为Symfony2提供HTML5应用程序缓存。
安装
$ composer require evheniy/html5-cache-bundle "1.*"
或添加到composer.json
"evheniy/html5-cache-bundle": "1.*"
AppKernel
public function registerBundles()
{
$bundles = array(
...
new Evheniy\HTML5CacheBundle\HTML5CacheBundle(),
);
...
config.yml
#HTML5CacheBundle
html5_cache: ~
or
#HTML5CacheBundle
html5_cache:
cdn: cdn.site.com
http: true
https: false
custom_urls:
- https://ajax.googleapis.ac.cn/ajax/libs/jquery/1.11.2/jquery.min.js
- https://maxcdn.bootstrap.ac.cn/bootstrap/3.3.4/css/bootstrap.min.css
- https://maxcdn.bootstrap.ac.cn/bootstrap/3.3.4/css/bootstrap-theme.min.css
- https://maxcdn.bootstrap.ac.cn/bootstrap/3.3.4/js/bootstrap.min.js
- ...
layout.html.twig
<html{{- cache_manifest()|raw -}}>
...
最后一步
app/console manifest:dump
文档
您可以使用本地CDN(域名)
html5_cache:
cdn: cdn.site.com
默认值为空
您可以设置本地CDN的协议
html5_cache:
cdn: cdn.site.com
http: true
https: false
默认值:true(两者都适用)
您可以设置自定义URL
html5_cache:
custom_urls:
- https://ajax.googleapis.ac.cn/ajax/libs/jquery/1.11.2/jquery.min.js
- https://maxcdn.bootstrap.ac.cn/bootstrap/3.3.4/css/bootstrap.min.css
- https://maxcdn.bootstrap.ac.cn/bootstrap/3.3.4/css/bootstrap-theme.min.css
- https://maxcdn.bootstrap.ac.cn/bootstrap/3.3.4/js/bootstrap.min.js
- ...
默认值为空
部分使用
layout.html.twig
<html{%- block cache_manifest -%}{%- endblock -%}>
...
page_with_cache.html.twig
{%- extends "layout.html.twig" -%}
{%- block cache_manifest -%}{{- cache_manifest()|raw -}}{%- endblock -%}
...
page_without_cache.html.twig
{%- extends "layout.html.twig" -%}
{%- block cache_manifest -%}{%- endblock -%}
...
JqueryBundle
如果您使用JqueryBundle,此URL将自动插入
https://ajax.googleapis.ac.cn/ajax/libs/jquery/{JqueryBundle.config.version}/jquery.min.js
TwitterBootstrapBundle
如果您使用TwitterBootstrapBundle,那些URL将自动插入
- https://maxcdn.bootstrap.ac.cn/bootstrap/{TwitterBootstrapBundle.config.version}/css/bootstrap.min.css
- https://maxcdn.bootstrap.ac.cn/bootstrap/{TwitterBootstrapBundle.config.version}/css/bootstrap-theme.min.css
- https://maxcdn.bootstrap.ac.cn/bootstrap/{TwitterBootstrapBundle.config.version}/js/bootstrap.min.js
MaterializeBundle
如果您使用MaterializeBundle,那些URL将自动插入
- https://cdnjs.cloudflare.com/ajax/libs/materialize/{MaterializeBundle.config.version}/css/materialize.min.css
- https://cdnjs.cloudflare.com/ajax/libs/materialize/{MaterializeBundle.config.version}/js/materialize.min.js
许可证
此捆绑包采用MIT许可证。
演示 - 打开页面,然后关闭网络并更新页面