SpeedKitConfig
activateStaticRouting?: boolean;
apiChangeDetection?: boolean | ApiChangeDetectionConfig;
appDomain?: string;
appName: string;
blacklist?: SpeedKitRule[];
blockedRequests?: SpeedKitRule[];
cookieLifetime?: number;
criticalResources?: CriticalResources;
customDevice?: string | (() => string | Promise<string>);
customVariation?: VariationRule[];
defer?: SpeedKitRule[];
delayed?: SpeedKitRule[] | DelayRule[];
detectDevice?: string | ((doc: Document) => string | Promise<string>);
dictionaryCompression?: boolean;
disableCache?: boolean;
disabled?: boolean;
disabledSites?: SpeedKitRule[];
disableParamSorting?: SpeedKitRule[];
dynamicBlockUrlTransform?: string | TransformFunction;
enabled?: boolean;
enabledAPIs?: SpeedKitRule[] | EnabledAPIRule[];
enabledSites?: SpeedKitRule[];
enableForWebViews?: boolean;
enableOriginCache?: boolean;
executeInIframe?: boolean;
fetchInUnload?: boolean;
fetchlist?: SpeedKitRule[];
fetchOriginInterval?: number;
group?: string;
ignoreAfterPostNavigate?: boolean;
image?: false | ImageOptions | ImageRule[];
immutableAssets?: SpeedKitRule[];
includeServiceWorker?: string;
maxStaleness?: number;
navigationPreload?: boolean;
offlinePage?: string;
omitImageCredentials?: boolean;
precache?: (string | PrecacheRule)[] | (() => (string | PrecacheRule)[]);
preloadBlacklist?: SpeedKitRule[];
preloadBloomFilter?: boolean;
preloadDynamicBlocks?: boolean | SpeedKitRule[];
reconnectInterval?: number;
refreshInterval?: number;
relativeModuleImports?: boolean;
resetResponseUrl?: SpeedKitRule[];
ruleSetConfig?: RuleSetConfig;
rumTracking?: boolean | TrackingOptions;
sampleRate?: number;
scope?: string;
sdnSetup?: boolean;
sessionLifetime?: number;
shouldDetectDevice?: SpeedKitRule[];
split?: number;
splitTestId?: string;
staleWhileRevalidate?: number;
stripQueryParams?: Condition | StripParamsRule[];
sw?: string;
trackingRequests?: SpeedKitRule[];
urlTransform?: TransformRule[];
useCacheWhenOffline?: boolean;
userAgentDetection?: boolean | SpeedKitRule[];
watchStorageKeys?: (string | RegExp)[];
whitelist?: SpeedKitRule[];
}
Index
Properties
Properties
Optional
activate Static Routing
Optional
api Change Detection
The configuration for the API Change Detection.
Optional
app Domain
The domain to connect to your Baqend app.
app Name
The name of your Baqend app.
Optional
blacklist
Some rules for requests which should not be intercepted.
Using an empty rule array means that Speed Kit is blacklisted for no resource (this is the default).
Optional
blocked Requests
Rules to identify requests which should be blocked by the Service Worker and answered with a status "blocked:SpeedKit".
Optional
cookie Lifetime
Specifies the lifetime of RUM Tracking Cookies in days.
Optional
critical Resources
Rules to identify critical resources of an HTML document.
You can use an array of ResourceRules to tell Speed Kit which are the critical resources of specific pages that should be handled with higher priority.
The config looks for example like this:
var speedKit = {
// ... other options ...
criticalResources: [{
// apply specific critical resources for different pages
enabledOn: [{ pathname: ['index.html'] }],
resources: ['/assets/picture.jpg'],
}, {
// global critical resources
resources: ['/assets/logo.png'],
}],
// ... other options ...
};
You can also just pass an array of strings to globally define critical resources for all pages of your site:
var speedKit = {
// ... other options ...
criticalResources: ['/assets/logo.png'],
// ... other options ...
};
Optional
custom Device
Set the device type inferred for the current user. If the device type is not set SpeedKit will determine it using the user agent and/or given custom variations.
Deprecated
Use SpeedKitConfig.detectDevice instead.
Optional
custom Variation
Applies a set of custom variation rules to Speed Kit requests. Unlike user agent detection this option can be configured with a custom function to determine the variation on a basis of currently set cookies and device type. Additionally, each rule can be configured regarding the sites on which it should be enabled and other conditions which have to be matched by the request. If two or more variation rules apply to a request, the rule defined last determines the variation.
Note: The provided function will only transmit an identifier for a custom variation to the server. In the server side runtime configuration a strategy for handling this variation (e.g. requesting assets with certain cookies) has to be defined.
Optional
defer
Defers the specified requests until the Dynamic Blocks are applied.
For this option to work the cached HTML needs to include a script tag /speed-kit-dom-ready.js
as first script. Also, the delayDOMLoadedEvent
option in the Dynamic Block config must be enabled.
Optional
delayed
Some rules for requests which should be intercepted but delayed.
You can use an array of DelayRules to tell Speed Kit how resources should be delayed. The config looks for example like this:
var speedKit = {
// ... other options ...
delayed: [
{
// Delay Google Tag Manager until one second after the load event
rules: [{ url: 'www.googletagmanager.com/gtm.js' }],
options: {
event: 'load',
timeout: 1000,
},
}, {
// apply options to resources under '/script/dynamic/'
rules: [{ pathname: '/script/dynamic/' }],
options: {
event: 'speed-kit-dynamic-loaded',
timeout: 0,
},
}
],
// ... other options ...
};
Delayed resources improve the critical rendering path of your website. All resources which are not matched by a rule will not be delayed by Speed Kit (this is the default).
You can also just pass an array of SpeedKitRules to this option if you do not want to specify the event up to which a resource is delayed (the "load" event is the default.):
var speedKit = {
// ... other options ...
delayed: {
[{ url: 'www.googletagmanager.com/gtm.js' }]
},
// ... other options ...
};
Example
[{ rules: [{ pathname: '/script/dynamic/' }], { event: 'speed-kit-dynamic-loaded', timeout: 2000 } }]
Optional
detect Device
Specifies the device of the current navigation.
Optional
dictionary Compression
Flag to enable automatic fetching of compression dictionaries for the browser to use. Based on the latest Bloomfilter response we obtain an id for fetching the currently active dictionary from the specified endpoint.
Optional
disable Cache
Disables using the ServiceWorker cache.
Optional
disabled
Whether to disable Speed Kit for the current user. This overrides the enabled flag.
Optional
disabled Sites
Rules to identify html sites on which Speed Kit should not be enabled.
Using an empty rule array means that Speed Kit is enabled on sites specified by enabledSites option.
Optional
disable Param Sorting
Ruleset to allow disabling of query parameter sorting.
We usually sort query parameters to avoid multiple cache entries because we use the URL as our cache key. In most cases this works, but sometimes the server response differs depending on the order of parameters. This option allows disabling the automatic sorting to ensure we always cache the correct content. By default, Parameter Sorting is disabled for all *.html requests.
Using an empty rule array means that the sorting is on for all requests.
Optional
dynamic Block Url Transform
A function to transform the dynamic block request url sent to origin.
Defines a custom function that transforms the url of the origin request used to fetch the personalized page which is used to switch out the Dynamic Blocks.
Optional
enabled
Whether to enable Speed Kit for the current user.
Optional
enabled AP Is
Rules to identify api requests that should bypass enabledSites/disabledSites checks.
Using an empty rule array means that no requests will bypass the checks.
Optional
enabled Sites
Rules to identify html sites on which Speed Kit should be enabled.
Using an empty rule array means that Speed Kit is enabled on every site.
Optional
enable For Web Views
Allows Speed Kit to be enabled within WebViews.
Optional
enable Origin Cache
Enables using the ServiceWorker cache for origin responses.
Optional
execute In Iframe
Whether the snippet shall be executed in an iFrame.
Depending on the configuration this includes tracking, setting of detected devices among others.
Optional
fetch In Unload
If this value is true, client will let service worker know when the page start unloading, and will fetch resources that is not in whitelist, blacklist, or fetchlist in the unload phase. If this value is false, client will not let service worker know and will also fetch resources that is not in whitelist, blacklist, or fetchlist both in and outside the unload phase.
Optional
fetchlist
Some rules for requests which should always be fetched from origin by the Service Worker.
Optional
fetch Origin Interval
An interval in which Speed Kit will call the original document, e.g., to receive its cookies.
In order to update your client's cookies or renew the user session, Speed Kit is
able to tee document requests so user-specific Set-Cookie
headers are asynchronously
fetched from your originating backend and applied in the browser.
The following values are allowed:
Value | Description |
---|---|
–1 | Do not tee the request (costs least bandwidth of your origin) – default. |
0 | Always tee the request (costs most bandwidth of your origin). |
X > 0 | Tee the request at most every X seconds (saves bandwidth of your origin). |
Optional
group
Assigned split group.
This can be used to force a specific group. Otherwise this will be determined automatically on client side.
Optional
ignore After Post Navigate
Whether Speed Kit blacklists first navigation after a Post Navigate.
Optional
image
Applies optimizations to images served by Speed Kit.
You can use an array of ImageRules to tell Speed Kit how images should be handled. The config looks for example like this:
var speedKit = {
// ... other options ...
image: [
{
// apply options to images under "/images/teasers/"
rules: [{ "pathname": "/images/teasers/" }],
options: {
optimize: 'high',
downscale: true,
},
}, {
// apply options to images under "/images/photos/"
rules: [{ "pathname": "/images/photos/" }],
options: {
optimize: 'medium',
webp: false,
},
}, {
// default options
options: {
optimize: 'medium',
webp: true,
downscale: false,
},
},
],
// ... other options ...
};
All images which are not matched by a rule will be applied with the default options (see ImageOptions).
You can also just pass an object of ImageOptions to this option if you want to override the defaults globally:
var speedKit = {
// ... other options ...
image: {
optimize: 'high' ,// change default optimization from medium to high
webp: false, // disable WebP support which is enabled by default
},
// ... other options ...
};
Example
[{ rules: [{ "pathname": "/assets/img/" }], options: { optimize: 'medium', downscale: true } }]
Optional
immutable Assets
Rules to identify assets that are immutable and therefore can always be taken from cache.
For security reasons, navigate requests can not be marked as immutable.
Optional
include Service Worker
Includes a 2nd-party service worker.
Optional
max Staleness
The refresh interval of the Bloom filter in milliseconds.
Deprecated
Use SpeedKitConfig.refreshInterval (in seconds) instead.
Optional
navigation Preload
Enables Navigation Preloads.
To learn more about Navigation Preloads read Google's Developer Blog.
Note: This should only be enabled when document requests are not served through Speed Kit, i.e. they are blacklisted. With this option enabled, all navigate requests are served by the origin server and will not be cached.
Optional
offline Page
Specifies a page that is always served when the client has no connection to the network.
Optional
omit Image Credentials
Sets the credentials header to 'omit' for image requests.
Optional
precache
A list of resources to be precached during Service Worker install event.
You can use an array of strings to tell Speed Kit which resources should be precached during the install event of the Service Worker. By that, the specified resources can be served by the bytecode cache of the browser (hot run) right after the Service Worker is installed.
From Speed Kit version 2.18.0, you can also set a callback to dynamically determine the strings or precache rules (e.g. using document.querySelector). The callback must return an array of strings or precache rules. This callback will be executed inside DOM context and only the resulting array wil be passed to the Service Worker.
Optional
preload Blacklist
Some rules for preload requests which should not be intercepted.
Using an empty rule array means that Speed Kit is preload blacklisted for no resource (this is the default).
Optional
preload Bloom Filter
Load the Bloom filter when activating Speed Kit.
Optional
preload Dynamic Blocks
Preloads the personalized version of the page for dynamic blocks
If enabled, Speed Kit loads the personalized version of the page from the origin right after the navigate request instead of waiting for the Dynamic Fetcher to be executed.
Note: This should only be enabled when the Dynamic Fetcher is in use. With this option enabled, all navigate requests handled by Speed Kit also trigger a fetch of the origin's version of the resource.
Optional
reconnect Interval
The interval in which to try to reconnect to the disconnected Baqend app in milliseconds.
Optional
refresh Interval
The refresh interval of the Bloom filter in seconds.
This option specifies the interval to refresh the Bloom filter, which is a cache sketch of changed resources on the server side. This interval effectively decides the maximum staleness of assets on your site.
Optional
relative Module Imports
Whether relative imports are used for JavaScript modules.
Optional
reset Response Url
Resets the response URL from the Speed Kit domain to the original URL.
Optional
rule Set Config
The configuration for parsing the ruleset. no prefix match on query params & no query parameter evaluation on pathname rule Version 2 will
- not evaluate query parameters on pathname rule
- not match prefixes on query parameters
Optional
rum Tracking
Enables Speed Kit Real User Monitoring (RUM).
Note: If activated, this option will make use of cookies to store user and session IDs.
You can also use TrackingOptions to specify how RUM tracking should behave.
Optional
sample Rate
Specifies the percentage of session that will send RUM data. Ranges from 0 to 1. RUM needs to be enabled for the sample rate to take effect.
Optional
scope
The Scope under which Speed Kit will be active.
Optional
sdn Setup
Whether Speed Kit runs in a Speed Kit Delivery Network (SDN) setup.
Note: This must be enabled when Speed Kit runs in the Speed Kit Delivery Network (SDN) setup.
Optional
session Lifetime
Specifies the lifetime of the user's session which is used for performance tracking.
Optional
should Detect Device
A custom set of rules which specify if device should be appended to the request via a query string.
Optional
split
Sets the probability that group A is chosen in the A/B test that enables Speed Kit for a percentage of users.
All users that are assigned to group "B"
will not benefit from Speed Kit but
serve as the control group to compare performance and business metrics against.
The value can vary from 0.0
to 1.0
. If you specify null
or any value
larger then 1.0
, all users whose browser supports Service Workers will
have Speed Kit enabled.
Also compare the following table for some example values:
Value | Description |
---|---|
0.00 |
Speed Kit is always disabled. |
0.50 |
50% of users will get Speed Kit enabled while the other 50% will be disabled. |
0.95 |
95% of users will get Speed Kit enabled while 5% will be disabled to serve as the control group. |
1.00 |
Speed Kit is always enabled for users with supporting browsers. |
null |
Speed Kit is always enabled (the default value). |
Optional
split Test Id
ID to identify the active split test.
Should be used in combination with split
to identify the active split test.
Change the split test id to start a new split test (e.g. when changing the split or configuration).
Optional
stale While Revalidate
A timespan in seconds in which the outdated Bloom filter may be temporarily used.
The user session length in seconds in which the Bloom filter is used to decide the staleness of HTML cache entries while being refreshed in the background. This setting increases cache hits for HTML files drastically and should represent the length of your users' sessions.
Explanation
If the Bloom filter is outside its refresh interval, Speed Kit can use the outdated Bloom filter once for an additional timespan of 30 minutes to take content from the cache while updating the Bloom filter in the background.
Optional
strip Query Params
Applies query parameter stripping to resources served by Speed Kit. Query params are only removed on network level. They can still be read and used in frontend code.
You can use an array of StripParamsRule to tell Speed Kit which query parameters should be stripped. The config looks for example like this:
var speedKit = {
// ... other options ...
stripQueryParams: [
{
// strip 'slow' param of resources under '/speed/' on enabled sites
enabledSites: [{ pathname: '/baqend/' }],
rules: [{ 'pathname': '/speed/' }],
params: ['slow'],
}, {
// strip 'country' query parameter of resources under '/product/prices/'
rules: [{ 'pathname': '/product/prices/' }],
params: ['country'],
}, {
// strip specified params for all resources
params: ['analytics', 'gclid'],
},
],
// ... other options ...
};
Alternatively, you can use a set of rules to match against query parameters to be stripped from all requested URLs. Every before they are fetched:
var speedKit = {
// ... other options ...
stripQueryParams: ['analytics', 'gclid'],
// ... other options ...
};
Optional
sw
Location of the service worker.
Optional
tracking Requests
Rules to identify tracking requests which send data to the origin. Those requests are answered with a 204 status code and the data is send to the origin by the Service Worker in the background.
Optional
url Transform
Applies a set of custom rules which modify Speed Kit requests URLs.
Optional
use Cache When Offline
Whether to respond to offline Requests with the SW cache.
Optional
user Agent Detection
Enables user agent detection to handle mobile and desktop differently.
If user agent detection is enabled, Speed Kit distinguishes all requests between mobile and desktop. Only activate this feature if you serve different assets for mobile and desktop users because it reduces your cache hit ratio.
You can also pass an array of SpeedKitRules to specify which resources should be distinguished.
Optional
watch Storage Keys
Specifies storage keys in localStorage
and sessionStorage
to watch for changes.
Speed Kit will monitor changes to these keys and synchronize them with the Service Worker.
Optional
whitelist
Some rules for requests which should be intercepted.
Using an empty rule array means that Speed Kit is whitelisted for every resource (this is the default).
If this value is true, blacklist and disabledSites rules will be converted to URLPatterns and added to static routing api. This feature only supports ruleSetVersion 2. If the version is 1, rules are not added to static routing api.