NoVarySearchHeader


@Profile.ExperimentalUrlPrefetch
public class NoVarySearchHeader


The No-Vary-Search data specifies a set of rules that define how a URL's query parameters will affect cache matching. These rules dictate whether the same URL with different URL parameters should be saved as separate browser cache entries.

See Doc here to learn more about No-Vary-Search.

Summary

Public fields

final @NonNull List<String>

A List of parameters that if present, will cause otherwise identical URLs to be cached as separate entries.

final boolean

A true to indicate the differences in parameters present between otherwise identical URLs will not cause them to be cached as separate entries.

final @NonNull List<String>

A List of parameters that if present, will not cause otherwise identical URLs to be cached as separate entries.

final boolean

If true this indicates that differences in the order of parameters between otherwise identical URLs will cause them to be cached as separate entries.

Public methods

static @NonNull NoVarySearchHeader

Returns No-Vary-Search data that considers all differences in query parameters (i.e. presence and ordering) between otherwise identical URLs in cache matching.

static @NonNull NoVarySearchHeader

Returns No-Vary-Search data that doesn't consider any differences in query parameters (i.e. presence or ordering) between otherwise identical URLs in cache matching.

static @NonNull NoVarySearchHeader
@Profile.ExperimentalUrlPrefetch
neverVaryExcept(
    boolean varyOnOrdering,
    @NonNull List<String> consideredQueryParameters
)

Returns No-Vary-Search data that doesn't consider differences in in query parameters present between otherwise identical URLs in cache matching with the exception of the ones provided in consideredQueryParameters.

static @NonNull NoVarySearchHeader
@Profile.ExperimentalUrlPrefetch
varyExcept(
    boolean varyOnOrdering,
    @NonNull List<String> ignoredQueryParameters
)

Returns No-Vary-Search data that considers differences in in query parameters present between otherwise identical URLs in cache matching with the exception of the ones provided in ignoredQueryParameters.

Public fields

consideredQueryParameters

public final @NonNull List<StringconsideredQueryParameters

A List of parameters that if present, will cause otherwise identical URLs to be cached as separate entries. Any parameters present in the URLs that are not included in this list will not affect cache matching.

This list is irrelevant and not used if ignoreDifferencesInParameters is false.

ignoreDifferencesInParameters

public final boolean ignoreDifferencesInParameters

A true to indicate the differences in parameters present between otherwise identical URLs will not cause them to be cached as separate entries. false otherwise.

ignoredQueryParameters

public final @NonNull List<StringignoredQueryParameters

A List of parameters that if present, will not cause otherwise identical URLs to be cached as separate entries. Any parameters present in the URLs that are not included in this list will affect cache matching.

This list is irrelevant and not used if ignoreDifferencesInParameters is true.

varyOnKeyOrder

public final boolean varyOnKeyOrder

If true this indicates that differences in the order of parameters between otherwise identical URLs will cause them to be cached as separate entries.

However, differences in the parameters present will cause them to be cached separately regardless of this flag's value.

To ignore any differences in parameters present for caching see ignoreDifferencesInParameters and ignoredQueryParameters. false otherwise.

Public methods

alwaysVaryData

@Profile.ExperimentalUrlPrefetch
public static @NonNull NoVarySearchHeader alwaysVaryData()

Returns No-Vary-Search data that considers all differences in query parameters (i.e. presence and ordering) between otherwise identical URLs in cache matching.

neverVaryData

@Profile.ExperimentalUrlPrefetch
public static @NonNull NoVarySearchHeader neverVaryData()

Returns No-Vary-Search data that doesn't consider any differences in query parameters (i.e. presence or ordering) between otherwise identical URLs in cache matching.

neverVaryExcept

@Profile.ExperimentalUrlPrefetch
public static @NonNull NoVarySearchHeader neverVaryExcept(
    boolean varyOnOrdering,
    @NonNull List<String> consideredQueryParameters
)

Returns No-Vary-Search data that doesn't consider differences in in query parameters present between otherwise identical URLs in cache matching with the exception of the ones provided in consideredQueryParameters.

Parameters
boolean varyOnOrdering

true if the ordering of query parameters should be considered in cache matching, false otherwise.

@NonNull List<String> consideredQueryParameters

the query parameters to consider in cache matching.

varyExcept

@Profile.ExperimentalUrlPrefetch
public static @NonNull NoVarySearchHeader varyExcept(
    boolean varyOnOrdering,
    @NonNull List<String> ignoredQueryParameters
)

Returns No-Vary-Search data that considers differences in in query parameters present between otherwise identical URLs in cache matching with the exception of the ones provided in ignoredQueryParameters.

Parameters
boolean varyOnOrdering

true if the ordering of query parameters should be considered in cache matching, false otherwise.

@NonNull List<String> ignoredQueryParameters

the query parameters to ignore in cache matching.