Sets default options for this package.
The maximum number of concurrently loading requests.
Additional requests are queued. Preload requests are always queued behind non-preload requests.
You might find it useful to set the request concurrency 1
in end-to-end tests
to prevent race conditions.
Note that your browser might impose its own request limit regardless of what you configure here.
Whether to wrap non-standard HTTP methods in a POST request.
If this is set, methods other than GET and POST will be converted to a POST
request
and carry their original method as a _method
parameter. This is to prevent unexpected redirect behavior.
If you disable method wrapping, make sure that your server always redirects with with a 303 status code (rather than 302).
The maximum number of responses to cache.
If the size is exceeded, the oldest responses will be dropped from the cache.
The number of milliseconds until a cached response expires.
Defaults to 5 minutes.
The connection's minimum effective bandwidth estimate required to prevent Unpoly from reducing requests.
The value is given in megabits per second. Higher is better.
The connection's maximum effective round-trip time required to prevent Unpoly from reducing requests.
The value is given in milliseconds. Lower is better.
How long the proxy waits until emitting the up:request:late
event.
Requests exceeding this response time will also cause a progress bar to appear at the top edge of the screen.
This metric is not considered for the decision to reduce requests.
The value is given in milliseconds.
Whether to cache the given request with { cache: 'auto' }
.
By default Unpoly will auto-cache requests with safe HTTP methods.
Whether to clear the cache after the given request and response. By default Unpoly will clear the entire cache after a request with an unsafe HTTP method.
An array of request property names that are sent to the server as HTTP headers.
The server may return an optimized response based on these properties, e.g. by omitting a navigation bar that is not targeted.
Two requests with different requestMetaKeys
are considered cache misses when caching and
preloading. To improve cacheability, you may set
up.network.config.requestMetaKeys
to a shorter list of property keys.
The default configuration is ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext']
.
This means the following properties are sent to the server:
You may also configure a function that accepts an up.Request
and returns
an array of request property names that are sent to the server.
With this you may send different request properties for different URLs:
up.network.config.requestMetaKeys = function(request) {
if (request.url == '/search') {
// The server optimizes responses on the /search route.
return ['target', 'failTarget']
} else {
// The server doesn't optimize any other route,
// so configure maximum cacheability.
return []
}
}
Whether to show a progress bar for late requests.
The progress bar is implemented as a single <up-progress-bar>
element.
Unpoly will automatically insert and remove this element as requests
are late or recovered.
The default appearance is a simple blue bar at the top edge of the screen. You may customize the style using CSS:
up-progress-bar {
background-color: red;
}