1

I am looking for a way of specifying a list of query parameters that I want to ignore for caching.

Can I use the directive CacheIgnoreURLSessionIdentifiers to ignore select query parameters regardless of whether they are used for session identifiers?

This causes cachable resources to be stored separately for each session, which is often not desired. CacheIgnoreURLSessionIdentifiers lets define a list of identifiers that are removed from the key that is used to identify an entity in the cache, such that cachable resources are not stored separately for each session.

  • AFAIK CacheIgnoreURLSessionIdentifiers doesn't prevent caching, but rather ignores the specified query string params when a resource is cached. So, if you specified foo and bar then /index.php?foo=1&bar=2 would be cached under the key /index.php - it's still cached. – MrWhite Sep 9 '16 at 20:36
  • ... or maybe that is what you require? You do still want the resource cached? ...mod_cache - server-side caching module. – MrWhite Sep 9 '16 at 20:55
  • @w3dk Thats what I want....want to ignore querystring parameters. I guess my question really is should CacheIgnoreURLSessionIdentifiers really be called CacheIgnoreQueryStringParameters as its not specific to session identifiers? – DD. Sep 10 '16 at 10:54
  • 1
    At least according to the docs, CacheIgnoreURLSessionIdentifiers does seem to apply to any query string params you specify. You'll have to try it. :) Why it makes such close reference to session identifiers I'm not sure, except that maybe session identifiers are probably it's most common usage. – MrWhite Sep 12 '16 at 10:46
1

Short version

Yes, you can use the directive CacheIgnoreURLSessionIdentifiers to ignore any query parameter for caching purposes (e.g. fbclid).

Just make sure that all URLs behind the cache behave the same, regardless of the existence and the value of the parameter. Else the cache might deliver wrong content.

Long version

The documentation only mentions session identifiers as an use case but states

CacheIgnoreURLSessionIdentifiers lets define a list of identifiers that are removed from the key that is used to identify an entity in the cache, such that cacheable resources are not stored separately for each session.

The implementation in modules/cache/cache_storage.c checks two cases:

/*
 * Check that we have a parameter separator in the last segment
 * of the path and that the parameter matches our identifier
 */

meaning that ;theidentifier=foobar is removed from the cache key, if there is such a parameter at the end of the path (and before the query string).

and

/*
 * Check if the identifier is in the query string and cut it out.
 */

meaning that theidentifier=foobar is removed from the query string part of the cache key. The code also does clean cutting, so that no trailing & or ? is left. As a result the cache handles a request for /index.html?theidentifier=foobar exactly like a request for /index.html.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.