evheniy / html5-cache-bundle
The HTML5CacheBundle adds the ability to add HTML5 Application Cache to your application.
Installs: 2 361
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
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-11-19 22:24:58 UTC
README
This bundle provides HTML5 Application Cache for Symfony2
Installation
$ composer require evheniy/html5-cache-bundle "1.*"
Or add to 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.com/ajax/libs/jquery/1.11.2/jquery.min.js
- https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css
- https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css
- https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js
- ...
layout.html.twig:
<html{{- cache_manifest()|raw -}}>
...
The last step
app/console manifest:dump
Documentation
You can use local CDN (domain):
html5_cache:
cdn: cdn.site.com
Default value is empty
You can set protocols for local CDN:
html5_cache:
cdn: cdn.site.com
http: true
https: false
Default value: true (for both)
You can set custom urls:
html5_cache:
custom_urls:
- https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
- https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css
- https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css
- https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js
- ...
Default value is empty
Partial using
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
If You are using JqueryBundle, this url:
https://ajax.googleapis.com/ajax/libs/jquery/{JqueryBundle.config.version}/jquery.min.js
will be inserted automatically
TwitterBootstrapBundle
If You are using TwitterBootstrapBundle, those urls:
- https://maxcdn.bootstrapcdn.com/bootstrap/{TwitterBootstrapBundle.config.version}/css/bootstrap.min.css
- https://maxcdn.bootstrapcdn.com/bootstrap/{TwitterBootstrapBundle.config.version}/css/bootstrap-theme.min.css
- https://maxcdn.bootstrapcdn.com/bootstrap/{TwitterBootstrapBundle.config.version}/js/bootstrap.min.js
will be inserted automatically
MaterializeBundle
If You are using MaterializeBundle, those urls:
- 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
will be inserted automatically
License
This bundle is under the MIT license.
Demo - Open page, then turn off network and update page