Managing urls in the manifest¶
Sometimes you don’t want urls to be cached for various reasons (they can pull content from external sites with no way to invalidate the local cache, or they are just non meant to be available offline), or you want to insert non-discoverable urls in it.
As there is not one-size-fit-all in managing urls in manifest,
django-html5-appcache
offers different methods to get the urls in or out
of the manifest file to meet as many usecases as possible.
Via configuration¶
To include urls in the manifest, use HTML5_APPCACHE_CACHED_URL
,
to exclude them use HTML5_APPCACHE_EXCLUDE_URL
.
To insert a URL in NETWORK see HTML5_APPCACHE_NETWORK_URL
; for
FALLBACK see HTML5_APPCACHE_FALLBACK_URL
.
Via AppCache class¶
In the AppCache
classes, is it possible to override methods to fine-tune
the urls in each section of the manifest file:
BaseAppCache._get_urls
: to add urls to the CACHE sectionBaseAppCache._get_assets
: to add assets to the CACHE sectionBaseAppCache._get_network
: to add urls to the NETWORK sectionBaseAppCache._get_fallback
: to add urls to the FALLBACK section
In the Markup¶
When using sitemap discovery
, by default
every relative URL is considered to be cached, while external URLs are not cached.
It’s possible to control the behavior of each url by using custom attributes
in your tags.
For each img
, script
and link
tag, you can add data-attributes to
control how each referenced url is considered:
data-appcache='appcache'
: the referenced url is added to the CACHE sectiondata-appcache='noappcache'
: the referenced url is added to the NETWORK sectiondata-appcache-fallback=URL
: the referenced url is added in the FALLBACK section, with URL as a target