In this section, we describe how you can specify which browser requests should be accelerated by Speed Kit and which should remain untouched.
Static Resources
Speed Kit accelerates browser requests by serving cached copies of your server's original data.
This works best on requests for static resources because they do not change often and thus can remain inside the caches for longer. In the Speed Kit config, you can define whitelist rules to identify such resources:
Only whitelisted requests will be sped up by Speed Kit, while all other requests will be directed against the original data source (e.g. your server). If a request does not match the whitelist rule it is automatically blacklisted.
Good candidates for whitelisting are:
- static HTML files
- images
- fonts
- scripts
- CDN-accelerated content
- external static assets
A simple whitelist could look like this:
whitelist: [
{
host: [
'www.your-website.com',
'fonts.gstatic.com',
'static.criteo.net'
]
},
{
url: [
'code.jquery.com/jquery-3.6.0.min.js'
]
}
]
Of course this rule needs to put together specifically for your website.
You could use a tool such as WebPageTest to identify the requests being made when your website is loaded and corresponding to this create your own whitelist rule.
For additional information more about advanced parameters please head here.
Uncacheable Resources
To prevent data staleness and other undesirable side effects, Speed Kit should never handle content that is inherently uncacheable.
Therefore, you should avoid whitelisting third-party services such as analytics, ads, or tracking pixels. For additional flexibility, however, you can also explicitly exclude some requests from the whitelist: Blacklisted requests will not be accelerated, even if they match a whitelist rule.
Blacklisting resources can be rather specific, for example, when your website is mostly static and only has a few specific portions that are uncacheable. For example, the Speed Kit configuration for a mostly static shop website might look like this:
whitelist: [
{
host: [
'shop.mostlystatic.com',
'fonts.gstatic.com',
'static.criteo.net'
]
},
{
url: [
'code.jquery.com/jquery-3.6.0.min.js'
]
}
],
blacklist: [
{
pathname: [
/account/i,
/basket/i,
/checkout/i
]
}
]
Please also remember to specifically blacklist admin-areas of your website as these otherwise will also be cached by Speed Kit if they match your whitelist rule.
For details on how to accelerate user-specific content (e.g. product recommendations), see our section on personalized content.
Syntax
The white- and blacklists in the Speed Kit config will accept paths as well as regular expressions and even complex rules. All list entries are treated as logical ORs.
To configure the whitelist and blacklist Baqend provides you with SpeedKitRule.
With this syntax, you are able to formulate complex rules for an individual whitelist and blacklist. For example, imagine your website loads some images over the third-party domain img.example-cdn.com. In general, you want all resources whose content type is an image to be served via Speed Kit. For this case, a valid whitelist could look like this:
whitelist: [
{
contentType: 'image'
}
]
Examples
Further examples can be found in our Configuration Examples.