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:

"html_stream": {
  "op": {
    "enable": true
  },
  "version": "V2",
  "stub": {
    "ttl_sec": 864000,
    "learning_mode": "NUMREQS",
    "reqs_to_learn": 3
  },
  "smart_sense": {
    "enable": true,
    "reload_perc_to_reset_stub": 10,
    "learning_period_increase_mode": "ADDITIVE",
    "learning_period_decrease_mode": "CONSTANT",
    "learning_period_modifier_constant": 2
  },
  "streaming_action_control_flags": {
    "advanced_use_nv_cookie_setting_apis": false
  },
  "skipped_tag_clusters": [
    {
      "name": "NewRelic",
      "regex": "(?s).*NREUM.*",
      "tag": "script"
    },
    {
      "name": "GoogleAnalytics",
      "regex": "(?s).*google-analytics.*",
      "tag": "script"
    }
  ]
 },

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 blockDescription
opA 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
versionThe version of HTML Streaming to be used. Default value is V2. V1 is a legacy setting and is no longer used.
ignored_http_headers

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:

  • Set-Cookie
  • Content-Encoding
  • Content-Length
  • Connection
  • Transfer-Encoding
stubThis 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.
skipped_tag_clusters

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:

  • tag, which specifies the tag name (script, style, meta, etc.)
  • a descriptive name
  • a regex
smart_senseA 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.
streaming_action_control_flags

A block containing a set of fields used to fine-tune the operation of HTML Streaming.

op

The op block can contain the following fields:

FieldDescription
enableSet to true, this enables the feature.The default is false
size_bytes

An optional integer value for the min/max file size for which this operation can be applied. For example,

"size_bytes" : {

   "min" : 1500
}

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.

min_cache_hit_count

Optional minimum number of cache hits for the resource before this operation will be applied. For example.

"min_cache_hit_count" : 1

means that the feature will not be applied until the resource has been served from the cache at least once.

The default is 0.

priority

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_ttlOptional minimum remaining TTL on the resource to qualify for this operation. The value must be suffixed by one of the following:
  • s: seconds
  • m: minutes
  • h: hours
  • d: days

stub

The stub block can contain the following fields:

FieldDescription
ttl_sec

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)

learning_mode

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 

  • TIMEELAPSED
  • NUMREQS

The default is NUMREQS

reqs_to_learn

An integer number of requests to use as the threshold that the "learning" of the page has reached stability.

The default is 5.

time_to_learn_sec

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

cache_key_additional_qualifier

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

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:

FieldDescription
enable

Set to true, this enables Smart Sense.

The default is true.

reload_perc_to_reset_stub

Percentage of requests reloaded, beyond which we disable the stub and begin relearning.

The default is 20.