Search


Search something to see results

SpeedKitConfig

interface 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

Configuration.SpeedKitConfig.activateStaticRoutingConfiguration.SpeedKitConfig.apiChangeDetectionConfiguration.SpeedKitConfig.appDomainConfiguration.SpeedKitConfig.appNameConfiguration.SpeedKitConfig.blacklistConfiguration.SpeedKitConfig.blockedRequestsConfiguration.SpeedKitConfig.cookieLifetimeConfiguration.SpeedKitConfig.criticalResourcesConfiguration.SpeedKitConfig.customDeviceConfiguration.SpeedKitConfig.customVariationConfiguration.SpeedKitConfig.deferConfiguration.SpeedKitConfig.delayedConfiguration.SpeedKitConfig.detectDeviceConfiguration.SpeedKitConfig.dictionaryCompressionConfiguration.SpeedKitConfig.disableCacheConfiguration.SpeedKitConfig.disabledConfiguration.SpeedKitConfig.disabledSitesConfiguration.SpeedKitConfig.disableParamSortingConfiguration.SpeedKitConfig.dynamicBlockUrlTransformConfiguration.SpeedKitConfig.enabledConfiguration.SpeedKitConfig.enabledAPIsConfiguration.SpeedKitConfig.enabledSitesConfiguration.SpeedKitConfig.enableForWebViewsConfiguration.SpeedKitConfig.enableOriginCacheConfiguration.SpeedKitConfig.executeInIframeConfiguration.SpeedKitConfig.fetchInUnloadConfiguration.SpeedKitConfig.fetchlistConfiguration.SpeedKitConfig.fetchOriginIntervalConfiguration.SpeedKitConfig.groupConfiguration.SpeedKitConfig.ignoreAfterPostNavigateConfiguration.SpeedKitConfig.imageConfiguration.SpeedKitConfig.immutableAssetsConfiguration.SpeedKitConfig.includeServiceWorkerConfiguration.SpeedKitConfig.maxStalenessConfiguration.SpeedKitConfig.navigationPreloadConfiguration.SpeedKitConfig.offlinePageConfiguration.SpeedKitConfig.omitImageCredentialsConfiguration.SpeedKitConfig.precacheConfiguration.SpeedKitConfig.preloadBlacklistConfiguration.SpeedKitConfig.preloadBloomFilterConfiguration.SpeedKitConfig.preloadDynamicBlocksConfiguration.SpeedKitConfig.reconnectIntervalConfiguration.SpeedKitConfig.refreshIntervalConfiguration.SpeedKitConfig.relativeModuleImportsConfiguration.SpeedKitConfig.resetResponseUrlConfiguration.SpeedKitConfig.ruleSetConfigConfiguration.SpeedKitConfig.rumTrackingConfiguration.SpeedKitConfig.sampleRateConfiguration.SpeedKitConfig.scopeConfiguration.SpeedKitConfig.sdnSetupConfiguration.SpeedKitConfig.sessionLifetimeConfiguration.SpeedKitConfig.shouldDetectDeviceConfiguration.SpeedKitConfig.splitConfiguration.SpeedKitConfig.splitTestIdConfiguration.SpeedKitConfig.staleWhileRevalidateConfiguration.SpeedKitConfig.stripQueryParamsConfiguration.SpeedKitConfig.swConfiguration.SpeedKitConfig.trackingRequestsConfiguration.SpeedKitConfig.urlTransformConfiguration.SpeedKitConfig.useCacheWhenOfflineConfiguration.SpeedKitConfig.userAgentDetectionConfiguration.SpeedKitConfig.watchStorageKeysConfiguration.SpeedKitConfig.whitelist

Properties

activateStaticRouting?: boolean

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.

false

2.19.0

apiChangeDetection?: boolean | ApiChangeDetectionConfig

The configuration for the API Change Detection.

2.17.0

appDomain?: string

The domain to connect to your Baqend app.

speed-kit.example.org
appName: string

The name of your Baqend app.

blacklist?: SpeedKitRule[]

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).

[{ url: /robots\.txt$/, contentType: ["document"] }]
[]
blockedRequests?: SpeedKitRule[]

Rules to identify requests which should be blocked by the Service Worker and answered with a status "blocked:SpeedKit".

[]
[{ url: "www.baqend.com/speedkit/mustBeBlocked.js" }]

2.13.0

cookieLifetime?: number

Specifies the lifetime of RUM Tracking Cookies in days.

180

2.4.0

criticalResources?: CriticalResources

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 ...
};
[{ enabledOn: [{ pathname: ["index.html"] }], resources: ["/assets/logo.png"] }]
[]

1.11.0

customDevice?: string | (() => string | Promise<string>)

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.

Use SpeedKitConfig.detectDevice instead.

2.2.0

customVariation?: VariationRule[]

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.

[]

1.21.0

defer?: SpeedKitRule[]

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.

[{ pathname: '/script/dynamic/' }]

In this example, Speed Kit will not deliver the response for the request matching /script/dynamic/ until the Dynamic Fetcher has released the speed-kit-dom-ready.js file.

[]

2.4.0

delayed?: SpeedKitRule[] | DelayRule[]

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 ...
};
[{ rules: [{ pathname: '/script/dynamic/' }], { event: 'speed-kit-dynamic-loaded', timeout: 2000 } }]

In this example, Speed Kit will delay all resources under the '/script/dynamic/' path after the 'speed-kit-dynamic-loaded' event was fired plus a two second timeout. All other resources will not be delayed at all.

[]

1.17.0

detectDevice?: string | ((doc: Document) => string | Promise<string>)

Specifies the device of the current navigation.

[]

2.13.0

dictionaryCompression?: boolean

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.

2.19.0

disableCache?: boolean

Disables using the ServiceWorker cache.

false
disabled?: boolean

Whether to disable Speed Kit for the current user. This overrides the enabled flag.

false
disabledSites?: SpeedKitRule[]

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.

[]
[{ url: /^www\.baqend\.com/speedkit//}]

2.2.0

disableParamSorting?: SpeedKitRule[]

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.

[{ contentType: [ContentType.Navigate] }, { pathname: /\.html/ }]
dynamicBlockUrlTransform?: string | TransformFunction

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.

2.15.0

enabled?: boolean

Whether to enable Speed Kit for the current user.

true

2.7.0

enabledAPIs?: SpeedKitRule[] | EnabledAPIRule[]

Rules to identify api requests that should bypass enabledSites/disabledSites checks.

Using an empty rule array means that no requests will bypass the checks.

[]
[{ pathname: '/api/' }]

2.17.0

enabledSites?: SpeedKitRule[]

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.

[]
[{ url: /^www\.baqend\.com/speedkit//}]

1.1.1

enableForWebViews?: boolean

Allows Speed Kit to be enabled within WebViews.

false

2.6.1

enableOriginCache?: boolean

Enables using the ServiceWorker cache for origin responses.

false

2.10.0

executeInIframe?: boolean

Whether the snippet shall be executed in an iFrame.

Depending on the configuration this includes tracking, setting of detected devices among others.

false

2.6.0

fetchInUnload?: boolean

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.

true

2.17.0

fetchlist?: SpeedKitRule[]

Some rules for requests which should always be fetched from origin by the Service Worker.

[{ url: /robots\.txt$/, contentType: ["document"] }]
[]
fetchOriginInterval?: number

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).
60

The request will only be teed against your origin backend when the last call has not been made more than one minute ago.

-1

1.2.0

group?: string

Assigned split group.

This can be used to force a specific group. Otherwise this will be determined automatically on client side.

ignoreAfterPostNavigate?: boolean

Whether Speed Kit blacklists first navigation after a Post Navigate.

true

1.20.0

image?: false | ImageOptions | ImageRule[]

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 ...
};
[{ rules: [{ "pathname": "/assets/img/" }], options: { optimize: 'medium', downscale: true } }]

In this example, Speed Kit will compress all images under the "/assets/img/" path with medium optimization and limit its size to the user's screen. All other images will not be manipulated at all.

You can disable the feature completely by setting the option to false.

1.5.0

immutableAssets?: SpeedKitRule[]

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.

[]
[{ url: /^www\.baqend\.com/speedkit/immutable\.js/}]

2.4.0

includeServiceWorker?: string

Includes a 2nd-party service worker.

2.8.0

maxStaleness?: number

The refresh interval of the Bloom filter in milliseconds.

Use SpeedKitConfig.refreshInterval (in seconds) instead.

300000
navigationPreload?: boolean

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.

false
offlinePage?: string

Specifies a page that is always served when the client has no connection to the network.

"www.baqend.com/offline.html"

2.6.0

omitImageCredentials?: boolean

Sets the credentials header to 'omit' for image requests.

2.11.0

precache?: (string | PrecacheRule)[] | (() => (string | PrecacheRule)[])

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.

[]

2.4.0

preloadBlacklist?: SpeedKitRule[]

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).

[{ url: /robots\.txt$/, contentType: ["document"] }]
[]
preloadBloomFilter?: boolean

Load the Bloom filter when activating Speed Kit.

true
preloadDynamicBlocks?: boolean | SpeedKitRule[]

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.

false

1.15.0

reconnectInterval?: number

The interval in which to try to reconnect to the disconnected Baqend app in milliseconds.

60000

1.1.0

refreshInterval?: number

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.

300

Every 5 minutes, Speed Kit will synchronize the Bloom filter with the next request handles.

300
relativeModuleImports?: boolean

Whether relative imports are used for JavaScript modules.

true

1.13.0

resetResponseUrl?: SpeedKitRule[]

Resets the response URL from the Speed Kit domain to the original URL.

2.11.0

ruleSetConfig?: RuleSetConfig

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
rumTracking?: boolean | TrackingOptions

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.

false

1.20.0

sampleRate?: number

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.

1

2.8.0

scope?: string

The Scope under which Speed Kit will be active.

"/"
sdnSetup?: boolean

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.

false

2.6.0

sessionLifetime?: number

Specifies the lifetime of the user's session which is used for performance tracking.

Value is set to constant 1800 (30 minutes) since 2.10.4

1800

1.16.0

shouldDetectDevice?: SpeedKitRule[]

A custom set of rules which specify if device should be appended to the request via a query string.

[{ contentType: ['document'] }]

2.13.0

split?: number

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).
splitTestId?: string

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).

staleWhileRevalidate?: number

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.

1800

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.

1800
stripQueryParams?: Condition | StripParamsRule[]

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 ...
};
[{ enabledSites: [{ 'pathname': '/products/' }], params: ['size', 'color'] }]

Speed Kit will remove “size” and “color” query parameters for all resources requested by enabled sites under '/products/'. For all other sites, the query parameters won't be removed.

[]

1.17.0

sw?: string

Location of the service worker.

"/sw.js"
trackingRequests?: SpeedKitRule[]

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.

[]
[{ url: "www.baqend.com/speedkit/sendTracking.js" }]

2.5.0

urlTransform?: TransformRule[]

Applies a set of custom rules which modify Speed Kit requests URLs.

[]

2.12.0

useCacheWhenOffline?: boolean

Whether to respond to offline Requests with the SW cache.

2.11.0

userAgentDetection?: boolean | SpeedKitRule[]

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.

false
[{ contentType: ["document"]}]

This example shows the most common use case where Speed Kit will distinguish only the HTML requests. I.e. Speed Kit will serve different HTML files for desktop and mobile (if the origin provides them) but the same JS, CSS and image files.

watchStorageKeys?: (string | RegExp)[]

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.

['authToken', /^userPreference_/]
[]

2.17.0

whitelist?: SpeedKitRule[]

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).

[{ pathname: "/assets" }]
[]