Prefetch headers

I’d like to manually send prefetch requests to the XDN. The docs say that x-xdn-prefetch: 1 header should be used for this. However, even when correct header is provided within the request, on cache miss I receive status 200 instead of 412 PRECONDITION FAILED. Request travels full way instead of stopping on edge cache.
Can someone please help me on how to send correct prefetch requests to XDN?

Could you point us where it says that in the docs? On the prefetch page it says that you need to send query parameter xdn_prefetch=1 (Moovweb XDN Documentation - Prefetching).


According your question about docs:


To prefetch a URL, call the following from JavaScript running in the browser window:

import { prefetch } from '@xdn/prefetch/window';

This will send a request with the following header:

  • x-xdn-prefetch: 1
1 Like

@ierceg from what i understood, XDN service-worker expect query param but then it sends x-xdn-prefetch header. We don’t use nor RSF nor XDN service-worker, but we’d like to use this feature.

@Andrew.Borisenko thank you for pointing that out - we will fix that in the next release.

@arturkin You just need to add xdn_prefetch=1 query string to your fetches. It will not impact the caching because it gets removed before the cache evaluation.

1 Like

Thanks @ierceg, it works with query param.
Why header was dropped? It may be useful for custom implementation like we do.

Glad to hear it.

We dropped the header because query params, unlike custom request headers, can be set in the tags. At the time it was a private implementation detail (though clearly we missed the package README)

1 Like