HTML Streaming Configuration
HTML Streaming improves performance by streaming the non-unique parts of dynamic HTML pages to the requesting browser while the backend server is generating the unique dynamic HTML. This allows the browser to make use of previously wasted time to begin processing the non-unique HTML while the backend server is generating the unique HTML.
To be able to do this, the service automatically analyzes the HTML for the same page or application as it flows to multiple end users. The service then intelligently determines which portions of the HTML are non-unique across all users — for example, the top portion of the HTML in the HEAD section that contains metadata, scripts, and style sheet information. Once it learns the pattern for that page, the non-unique portions of the HTML are cached.
When the dynamic HTML is requested in the future, the service immediately sends the cached non-unique HTML to the requesting browser along with the Nanovisor while simultaneously sending a request to the backend web servers to generate the user-specific dynamic HTML. By sending the non-unique HTML to the browser immediately, it unblocks downloading of required assets and even allows parsing of scripts and style information required to render the page. Once the dynamic HTML is received by the service, it forwards this along to the requesting browser where it is patched in by the Nanovisor. As a result, the browser can finish rendering the page much earlier than is traditionally possible.
For more information about the HTML Streaming feature, read the document What is HTML Streaming?
HTML Streaming is controlled with the html_stream block inside performance and delivery rules. Here's a typical block:
The nanovisor block must be present for HTML Streaming to function, and the inject_instart flag inside it must be set to true.
Fields and blocks
The following fields and blocks can be used in the html_stream block:
|Field or block||Description|
|op||A content operation block where the feature can be enabled, and constraints configured for not applying it even though enabled – for example, min/max file sizes for which this operation can be applied|
|version||The version of HTML Streaming to be used. Default value is V2. V1 is a legacy setting and is no longer used.|
An optional field which allows you to add a list of additional HTTP headers that will be ignored when checking for a header match after the Instart service receives dynamic HTML. By default the following headers are ignored to allow this feature to work properly:
|stub||This block applies settings to control how the service learns the HTML Streaming stub, which is the initial portion of the HTML that will be streamed to the client once it's been learned by the system.|
A list of regular expressions that are used to identify elements in the HEAD (for example, scripts, links, metatags, style, etc.) that should be left in the stub. A "cluster" refers to the group of scripts that match the regular expression. Each cluster in the list has three string fields:
|smart_sense||A block used to configure the SmartSequence processor. SmartSequence automatically detects if too many reloads are occuring and if so, disables the stub and begins relearning with an increased learning period.|
A block containing a set of fields used to fine-tune the operation of HTML Streaming.
The op block can contain the following fields:
|enable||Set to true, this enables the feature.The default is false|
An optional integer value for the min/max file size for which this operation can be applied. For example,
will cause the feature to only be applied to files that are larger than 1500 bytes.
If not specified, max has a default of 100000000.
Optional minimum number of cache hits for the resource before this operation will be applied. For example.
means that the feature will not be applied until the resource has been served from the cache at least once.
The default is 0.
Optional priority of the operation in the queue for processing. 0 is lowest, and maximum value of uint32 is highest priority.
The default is 0.
|min_ttl||Optional minimum remaining TTL on the resource to qualify for this operation. The value must be suffixed by one of the following:|
The stub block can contain the following fields:
TTL in seconds for the HTML Streaming stub cache. After the TTL time the cache will be automatically updated with the new content if the page is accessed. To store forever, use -1.
The default is 3600 (1 hour)
Selects to use the time elapsed or the number of requests to select the threshold that determines if the HTML Streaming stub has been relearned, and a new version is ready to be written to the cache.
Possible modes are
The default is NUMREQS
An integer number of requests to use as the threshold that the "learning" of the page has reached stability.
The default is 5.
Time elapsed, in seconds, to use as the threshold used to decide that the "learning" of the page has reached stability.
The default is 60
Allows adding Nginx variables (like request headers, cookies etc.) in the HTS stub cache key.
A list of available Nginx variables can be found here: http://nginx.org/en/docs/varindex.html
The default is <url>.<HTML Streaming version>.<browser>
Smart Sense automatically detects if too many reloads are occurring and if so, disables the stub and begins relearning with an increased learning period.
The smart_sense block can contain the following fields:
Set to true, this enables Smart Sense.
The default is true.
Percentage of requests reloaded, beyond which we disable the stub and begin relearning.
The default is 20.