evheniy/html5-cache-bundle

HTML5CacheBundle可以向您的应用程序添加HTML5应用程序缓存的特性。

安装次数: 2,360

依赖项: 1

建议者: 0

安全性: 0

星标: 1

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

1.5.0 2018-04-09 19:06 UTC

This package is not auto-updated.

Last update: 2024-09-24 21:44:44 UTC


README

此捆绑包为Symfony2提供HTML5应用程序缓存。

knpbundles.com

Latest Stable Version Total Downloads Latest Unstable Version License

Build Status Coverage Status Scrutinizer Code Quality Build Status

安装

$ 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许可证。

俄语文档

演示 - 打开页面,然后关闭网络并更新页面

HTML5应用程序缓存