0
votes

I'm using memcached and Apache with the following default configuration

CacheEnable socache /
CacheSocache memcache:IP:PORT
MemcacheConnTTL 30

What will the behavior be when 30 seconds expire and a request for the same URL comes in? Is there a way to configure the cache key? I.e. what are the info which make a request unique? What if the server can't get an answer? (like timeout to fetch the newly updated object) Can it be configured to serve the old object?

Thanks

1

1 Answers

1
votes

What will the behavior be when 30 seconds expire and a request for the same URL comes in

Apache would simply create a new connection to memcached. It doesn’t mean something would happen to the data stored in memcached

https://httpd.apache.org/docs/2.4/mod/mod_socache_memcache.html#memcacheconnttl

Set the time to keep idle connections with the memcache server(s) alive (threaded platforms only).

If you need to control for how long an object will be stored in a cache, check out CacheDefaultExpire

Is there a way to configure the cache key

An url is used to build the key, but you can partially configure which parts of the url are used, check out CacheIgnoreQueryString, CacheIgnoreURLSessionIdentifiers

I.e. what are the info which make a request unique

https://httpd.apache.org/docs/2.4/mod/mod_cache.html#cacheenable

The CacheEnable directive instructs mod_cache to cache urls at or below url-string

Notice that not all requests can be cached, there’s a lot of rules on it

What if the server can't get an answer? Can it be configured to serve the old object

You need CacheStaleOnError

https://httpd.apache.org/docs/2.4/mod/mod_cache.html#cachestaleonerror

When the CacheStaleOnError directive is switched on, and when stale data is available in the cache, the cache will respond to 5xx responses from the backend by returning the stale data instead of the 5xx response