Publication Servers are responsible for providing the manifest, resources and APIs through HTTPS.
To optimize the user experience, each implementation should rely on HTTP caching.
For anyone unfamiliar with caching in HTTP, we highly recommend reading Mark Nottingham or Iliya Grigorik introductions to HTTP caching.
While the in-memory model and the subsequent manifest are most of the time fairly static resources, there are a number of use cases where they can change over time:
For these reasons, it’s best to revalidate with the server the freshness of a manifest using an ETag
.
We recommend each implementation to do the following:
ETag
Cache-Control
, Last-Modified
or Expires
304 Not Modified
if the ETag
matches the one provided by the client in the If-None-Match
headerPublication resources (listed in readingOrder
or resources
) served by the server are unlikely to change and should be cached more heavily than the manifest.
Having fonts, CSS or JS in cache can have a very positive impact on rendering time for HTML in a browser or a webview.
We recommend each implementation to do the following:
Cache-Control
to avoid any further requests between the client and the server once a resource is cachedCache-Control
should contain a public
directivemax-age
directive should be set, but this best practice document recommends caching resources for at least 24H or moreEach API exposed by the server is potentially unique and there’s no generic rule that can be applied.
That said, we can use the two examples above to provide some guidelines:
ETag
is the optimal solution but keep in mind that there’s a cost to it (calculating the ETag
and processing the request)Cache-Control
provides a very flexible mechanism that can be tweaked using the various directives available