refresh.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /* DEBUG: section 22 Refresh Calculation */
10 
11 #ifndef USE_POSIX_REGEX
12 #define USE_POSIX_REGEX /* put before includes; always use POSIX */
13 #endif
14 
15 #include "squid.h"
16 #include "HttpHdrCc.h"
17 #include "HttpReply.h"
18 #include "HttpRequest.h"
19 #include "MemObject.h"
20 #include "mgr/Registration.h"
21 #include "refresh.h"
22 #include "RefreshPattern.h"
23 #include "SquidConfig.h"
24 #include "SquidTime.h"
25 #include "Store.h"
26 #include "util.h"
27 
28 typedef enum {
31 #if USE_HTCP
33 #endif
34 #if USE_CACHE_DIGESTS
36 #endif
38  rcCount
40 
44 typedef struct {
45  bool expires;
46  bool min;
47  bool lmfactor;
48  bool max;
49 } stale_flags;
50 
51 /*
52  * This enumerated list assigns specific values, ala HTTP/FTP status
53  * codes. All Fresh codes are in the range 100-199 and all stale
54  * codes are 200-299. We might want to use these codes in logging,
55  * so best to keep them consistent over time.
56  */
57 enum {
73  STALE_DEFAULT = 299
74 };
75 
76 static struct RefreshCounts {
77  const char *proto;
78  int total;
81 
82 static const RefreshPattern *refreshUncompiledPattern(const char *);
84 static int refreshStaleness(const StoreEntry * entry, time_t check_time, const time_t age, const RefreshPattern * R, stale_flags * sf);
85 
86 static RefreshPattern DefaultRefresh("<none>", 0);
87 
92 const RefreshPattern *
93 refreshLimits(const char *url)
94 {
95  for (auto R = Config.Refresh; R; R = R->next) {
96  ++(R->stats.matchTests);
97  if (R->pattern.match(url)) {
98  ++(R->stats.matchCount);
99  return R;
100  }
101  }
102 
103  return nullptr;
104 }
105 
114 static const RefreshPattern *
115 refreshUncompiledPattern(const char *pat)
116 {
117  for (auto R = Config.Refresh; R; R = R->next) {
118  if (0 == strcmp(R->pattern.c_str(), pat))
119  return R;
120  }
121 
122  return nullptr;
123 }
124 
146 static int
147 refreshStaleness(const StoreEntry * entry, time_t check_time, const time_t age, const RefreshPattern * R, stale_flags * sf)
148 {
149  // 1. If the cached object has an explicit expiration time, then we rely on this and
150  // completely ignore the Min, Percent and Max values in the refresh_pattern.
151  if (entry->expires > -1) {
152  sf->expires = true;
153 
154  if (entry->expires > check_time) {
155  debugs(22, 3, "FRESH: expires " << entry->expires <<
156  " >= check_time " << check_time << " ");
157 
158  return -1;
159  } else {
160  debugs(22, 3, "STALE: expires " << entry->expires <<
161  " < check_time " << check_time << " ");
162 
163  return (check_time - entry->expires);
164  }
165  }
166 
167  debugs(22, 3, "No explicit expiry given, using heuristics to determine freshness");
168 
169  // 2. If the entry is older than the maximum age in the refresh_pattern, it is STALE.
170  if (age > R->max) {
171  debugs(22, 3, "STALE: age " << age << " > max " << R->max << " ");
172  sf->max = true;
173  return (age - R->max);
174  }
175 
176  // 3. If there is a Last-Modified header, try the last-modified factor algorithm.
177  const time_t lastmod_delta = entry->timestamp - entry->lastModified();
178  if (lastmod_delta > 0) {
179  /* stale_age is the age of the response when it became/becomes stale according to
180  * the last-modified factor algorithm. It's how long we can consider the response
181  * fresh from the time we cached it.
182  */
183  time_t stale_age = static_cast<time_t>(lastmod_delta * R->pct);
184 
185  debugs(22,3, "Last modified " << lastmod_delta << " sec before we cached it, L-M factor " <<
186  (100.0 * R->pct) << "% = " << stale_age << " sec freshness lifetime");
187  sf->lmfactor = true;
188 
189  if (age >= stale_age) {
190  debugs(22, 3, "STALE: age " << age << " > stale_age " << stale_age);
191  return (age - stale_age);
192  } else {
193  debugs(22, 3, "FRESH: age " << age << " <= stale_age " << stale_age);
194  return -1;
195  }
196  }
197 
198  // 4. If the entry is not as old as the minimum age in the refresh_pattern, it is FRESH.
199  if (age < R->min) {
200  debugs(22, 3, "FRESH: age (" << age << " sec) is less than configured minimum (" << R->min << " sec)");
201  sf->min = true;
202  return -1;
203  }
204 
205  // 5. default is stale, by the amount we missed the minimum by
206  debugs(22, 3, "STALE: No explicit expiry, no last modified, and older than configured minimum.");
207  return (age - R->min);
208 }
209 
264 static int
265 refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta)
266 {
267  time_t age = 0;
268  time_t check_time = squid_curtime + delta;
269  int staleness;
270  stale_flags sf;
271 
272  // get the URL of this entry, if there is one
273  static const SBuf nilUri("<none>");
274  SBuf uri = nilUri;
275  if (entry->mem_obj)
276  uri = entry->mem_obj->storeId();
277  else if (request)
278  uri = request->effectiveRequestUri();
279 
280  debugs(22, 3, "checking freshness of URI: " << uri);
281 
282  // age is not necessarily the age now, but the age at the given check_time
283  if (check_time > entry->timestamp)
284  age = check_time - entry->timestamp;
285 
286  // XXX: what to do when age < 0 or counter overflow?
287  assert(age >= 0);
288 
289  /* We need a refresh rule. In order of preference:
290  *
291  * 1. the rule that matches this URI by regex
292  * 2. the "." rule from the config file
293  * 3. the default "." rule
294  */
295  // XXX: performance regression. c_str() reallocates
296  const RefreshPattern *R = (uri != nilUri) ? refreshLimits(uri.c_str()) : refreshUncompiledPattern(".");
297  if (NULL == R)
298  R = &DefaultRefresh;
299 
300  debugs(22, 3, "Matched '" << R->pattern.c_str() << " " <<
301  (int) R->min << " " << (int) (100.0 * R->pct) << "%% " <<
302  (int) R->max << "'");
303 
304  debugs(22, 3, "\tage:\t" << age);
305 
306  debugs(22, 3, "\tcheck_time:\t" << mkrfc1123(check_time));
307 
308  debugs(22, 3, "\tentry->timestamp:\t" << mkrfc1123(entry->timestamp));
309 
310  if (request && !request->flags.ignoreCc) {
311  const HttpHdrCc *const cc = request->cache_control;
312  int minFresh = -1;
313  if (cc && cc->hasMinFresh(&minFresh)) {
314  debugs(22, 3, "\tage + min-fresh:\t" << age << " + " <<
315  minFresh << " = " << age + minFresh);
316  debugs(22, 3, "\tcheck_time + min-fresh:\t" << check_time << " + "
317  << minFresh << " = " <<
318  mkrfc1123(check_time + minFresh));
319  age += minFresh;
320  check_time += minFresh;
321  }
322  }
323 
324  memset(&sf, '\0', sizeof(sf));
325 
326  staleness = refreshStaleness(entry, check_time, age, R, &sf);
327 
328  debugs(22, 3, "Staleness = " << staleness);
329 
330  const auto reply = entry->hasFreshestReply(); // may be nil
331 
332  // stale-if-error requires any failure be passed thru when its period is over.
333  int staleIfError = -1;
334  if (request && reply && reply->cache_control &&
335  reply->cache_control->hasStaleIfError(&staleIfError) &&
336  staleIfError < staleness) {
337 
338  debugs(22, 3, "stale-if-error period expired. Will produce error if validation fails.");
339  request->flags.failOnValidationError = true;
340  }
341 
342  /* If the origin server specified either of:
343  * Cache-Control: must-revalidate
344  * Cache-Control: proxy-revalidate
345  * the spec says the response must always be revalidated if stale.
346  */
347  const bool revalidateAlways = EBIT_TEST(entry->flags, ENTRY_REVALIDATE_ALWAYS);
348  if (revalidateAlways || (staleness > -1 &&
350  debugs(22, 3, "YES: Must revalidate stale object (origin set " <<
351  (revalidateAlways ? "no-cache or private" :
352  "must-revalidate, proxy-revalidate or s-maxage") << ")");
353  if (request)
354  request->flags.failOnValidationError = true;
355  return STALE_MUST_REVALIDATE;
356  }
357 
358  /* request-specific checks */
359  if (request && !request->flags.ignoreCc) {
360  HttpHdrCc *cc = request->cache_control;
361 
362  /* If the request is an IMS request, and squid is configured NOT to service this from cache
363  * (either by 'refresh-ims' in the refresh pattern or 'refresh_all_ims on' globally)
364  * then force a reload from the origin.
365  */
366  if (request->flags.ims && (R->flags.refresh_ims || Config.onoff.refresh_all_ims)) {
367  // The client's no-cache header is changed into a IMS query
368  debugs(22, 3, "YES: Client IMS request forcing revalidation of object (refresh-ims option)");
369  return STALE_FORCED_RELOAD;
370  }
371 
372 #if USE_HTTP_VIOLATIONS
373  /* Normally a client reload request ("Cache-Control: no-cache" or "Pragma: no-cache")
374  * means we must treat this response as STALE and fetch a new one.
375  *
376  * However, some options exist to override this behaviour. For example, we might just
377  * revalidate our existing response, or even just serve it up without revalidating it.
378  *
379  * ---- Note on the meaning of nocache_hack -----
380  *
381  * The nocache_hack flag has a very specific and complex meaning:
382  *
383  * (a) this is a reload request ("Cache-Control: no-cache" or "Pragma: no-cache" header)
384  * and (b) the configuration file either has at least one refresh_pattern with
385  * ignore-reload or reload-into-ims (not necessarily the rule matching this request) or
386  * the global reload_into_ims is set to on
387  *
388  * In other words: this is a client reload, and we might need to override
389  * the default behaviour (but we might not).
390  *
391  * "nocache_hack" is a pretty deceptive name for such a complicated meaning.
392  */
393  if (request->flags.noCacheHack()) {
394 
395  if (R->flags.ignore_reload) {
396  /* The client's no-cache header is ignored completely - we'll try to serve
397  * what we have (assuming it's still fresh, etc.)
398  */
399  debugs(22, 3, "MAYBE: Ignoring client reload request - trying to serve from cache (ignore-reload option)");
400  } else if (R->flags.reload_into_ims || Config.onoff.reload_into_ims) {
401  /* The client's no-cache header is not honoured completely - we'll just try
402  * to revalidate our cached copy (IMS to origin) instead of fetching a new
403  * copy with an unconditional GET.
404  */
405  debugs(22, 3, "YES: Client reload request - cheating, only revalidating with origin (reload-into-ims option)");
406  return STALE_RELOAD_INTO_IMS;
407  } else {
408  /* The client's no-cache header is honoured - we fetch a new copy from origin */
409  debugs(22, 3, "YES: Client reload request - fetching new copy from origin");
410  request->flags.noCache = true;
411  return STALE_FORCED_RELOAD;
412  }
413  }
414 #endif
415 
416  // Check the Cache-Control client request header
417  if (NULL != cc) {
418 
419  // max-age directive
420  int maxAge = -1;
421  if (cc->hasMaxAge(&maxAge)) {
422 
423  // RFC 8246: reply contains CC:immutable then ignore client CC:max-age=N
424  if (reply && reply->cache_control && reply->cache_control->hasImmutable()) {
425  debugs(22, 3, "MAYBE: Ignoring client CC:max-age=" << maxAge << " request - 'Cache-Control: immutable'");
426 
427 #if USE_HTTP_VIOLATIONS
428  // Ignore of client "Cache-Control: max-age=0" header
429  } else if (R->flags.ignore_reload && maxAge == 0) {
430  debugs(22, 3, "MAYBE: Ignoring client reload request - trying to serve from cache (ignore-reload option)");
431 #endif
432 
433  // Honour client "Cache-Control: max-age=x" header
434  } else if (age > maxAge || maxAge == 0) {
435  debugs(22, 3, "YES: Revalidating object - client 'Cache-Control: max-age=" << maxAge << "'");
437  }
438  }
439 
440  // max-stale directive
441  int maxStale = -1;
442  if (cc->hasMaxStale(&maxStale) && staleness > -1) {
443  if (maxStale==HttpHdrCc::MAX_STALE_ANY) {
444  debugs(22, 3, "NO: Client accepts a stale response of any age - 'Cache-Control: max-stale'");
446  } else if (staleness < maxStale) {
447  debugs(22, 3, "NO: Client accepts a stale response - 'Cache-Control: max-stale=" << maxStale << "'");
449  }
450  }
451  }
452  }
453 
454  // If the object is fresh, return the right FRESH_ code
455  if (-1 == staleness) {
456  debugs(22, 3, "Object isn't stale..");
457  if (sf.expires) {
458  debugs(22, 3, "returning FRESH_EXPIRES");
459  return FRESH_EXPIRES;
460  }
461 
462  assert(!sf.max);
463 
464  if (sf.lmfactor) {
465  debugs(22, 3, "returning FRESH_LMFACTOR_RULE");
466  return FRESH_LMFACTOR_RULE;
467  }
468 
469  assert(sf.min);
470 
471  debugs(22, 3, "returning FRESH_MIN_RULE");
472  return FRESH_MIN_RULE;
473  }
474 
475  /*
476  * At this point the response is stale, unless one of
477  * the override options kicks in.
478  * NOTE: max-stale config blocks the overrides.
479  */
480  int max_stale = (R->max_stale >= 0 ? R->max_stale : Config.maxStale);
481  if ( max_stale >= 0 && staleness > max_stale) {
482  debugs(22, 3, "YES: refresh_pattern max-stale=N limit from squid.conf");
483  if (request)
484  request->flags.failOnValidationError = true;
485  return STALE_MAX_STALE;
486  }
487 
488  if (sf.expires) {
489 #if USE_HTTP_VIOLATIONS
490 
491  if (R->flags.override_expire && age < R->min) {
492  debugs(22, 3, "NO: Serving from cache - even though explicit expiry has passed, we enforce Min value (override-expire option)");
493  return FRESH_OVERRIDE_EXPIRES;
494  }
495 
496 #endif
497  return STALE_EXPIRES;
498  }
499 
500  if (sf.max)
501  return STALE_MAX_RULE;
502 
503  if (sf.lmfactor) {
504 #if USE_HTTP_VIOLATIONS
505  if (R->flags.override_lastmod && age < R->min) {
506  debugs(22, 3, "NO: Serving from cache - even though L-M factor says the object is stale, we enforce Min value (override-lastmod option)");
507  return FRESH_OVERRIDE_LASTMOD;
508  }
509 #endif
510  debugs(22, 3, "YES: L-M factor says the object is stale'");
511  return STALE_LMFACTOR_RULE;
512  }
513 
514  debugs(22, 3, "returning STALE_DEFAULT");
515  return STALE_DEFAULT;
516 }
517 
528 bool
530 {
531  /*
532  * Don't look at the request to avoid no-cache and other nuisances.
533  * the object should have a mem_obj so the URL will be found there.
534  * minimum_expiry_time seconds delta (defaults to 60 seconds), to
535  * avoid objects which expire almost immediately, and which can't
536  * be refreshed.
537  */
538  int reason = refreshCheck(entry, NULL, Config.minimum_expiry_time);
540  ++ refreshCounts[rcStore].status[reason];
541 
542  if (reason < STALE_MUST_REVALIDATE)
543  /* Does not need refresh. This is certainly cachable */
544  return true;
545 
546  if (entry->lastModified() < 0)
547  /* We should know entry's modification time to do a refresh */
548  return false;
549 
550  if (entry->mem_obj == NULL)
551  /* no mem_obj? */
552  return true;
553 
554  if (entry->mem_obj->baseReply().content_length == 0)
555  /* No use refreshing (caching?) 0 byte objects */
556  return false;
557 
558  /* This seems to be refreshable. Cache it */
559  return true;
560 }
561 
563 static bool
564 refreshIsStaleIfHit(const int reason)
565 {
566  switch (reason) {
567  case FRESH_MIN_RULE:
568  case FRESH_LMFACTOR_RULE:
569  case FRESH_EXPIRES:
570  return false;
571  default:
572  return true;
573  }
574 }
575 
584 int
586 {
587  int reason = refreshCheck(entry, request, 0);
589  ++ refreshCounts[rcHTTP].status[reason];
590  request->flags.staleIfHit = refreshIsStaleIfHit(reason);
591  // TODO: Treat collapsed responses as fresh but second-hand.
592  return (Config.onoff.offline || reason < 200) ? 0 : 1;
593 }
594 
596 int
598 {
599  int reason = refreshCheck(entry, request, 30);
601  ++ refreshCounts[rcICP].status[reason];
602  return (reason < 200) ? 0 : 1;
603 }
604 
605 #if USE_HTCP
606 int
609 {
610  int reason = refreshCheck(entry, request, 10);
612  ++ refreshCounts[rcHTCP].status[reason];
613  return (reason < 200) ? 0 : 1;
614 }
615 
616 #endif
617 
618 #if USE_CACHE_DIGESTS
619 int
621 refreshCheckDigest(const StoreEntry * entry, time_t delta)
622 {
623  int reason = refreshCheck(entry,
624  entry->mem_obj ? entry->mem_obj->request.getRaw() : nullptr,
625  delta);
627  ++ refreshCounts[rcCDigest].status[reason];
628  return (reason < 200) ? 0 : 1;
629 }
630 #endif
631 
642 time_t
643 getMaxAge(const char *url)
644 {
645  const RefreshPattern *R;
646  debugs(22, 3, "getMaxAge: '" << url << "'");
647 
648  if ((R = refreshLimits(url)))
649  return R->max;
650  else
651  return REFRESH_DEFAULT_MAX;
652 }
653 
654 static int
655 refreshCountsStatsEntry(StoreEntry * sentry, struct RefreshCounts &rc, int code, const char *desc)
656 {
657  storeAppendPrintf(sentry, "%6d\t%6.2f\t%s\n", rc.status[code], xpercent(rc.status[code], rc.total), desc);
658  return rc.status[code];
659 }
660 
661 static void
663 {
664  if (!rc.total)
665  return;
666 
667  storeAppendPrintf(sentry, "\n\n%s histogram:\n", rc.proto);
668  storeAppendPrintf(sentry, "Count\t%%Total\tCategory\n");
669 
670  int sum = 0;
671  sum += refreshCountsStatsEntry(sentry, rc, FRESH_REQUEST_MAX_STALE_ALL, "Fresh: request max-stale wildcard");
672  sum += refreshCountsStatsEntry(sentry, rc, FRESH_REQUEST_MAX_STALE_VALUE, "Fresh: request max-stale value");
673  sum += refreshCountsStatsEntry(sentry, rc, FRESH_EXPIRES, "Fresh: expires time not reached");
674  sum += refreshCountsStatsEntry(sentry, rc, FRESH_LMFACTOR_RULE, "Fresh: refresh_pattern last-mod factor percentage");
675  sum += refreshCountsStatsEntry(sentry, rc, FRESH_MIN_RULE, "Fresh: refresh_pattern min value");
676  sum += refreshCountsStatsEntry(sentry, rc, FRESH_OVERRIDE_EXPIRES, "Fresh: refresh_pattern override-expires");
677  sum += refreshCountsStatsEntry(sentry, rc, FRESH_OVERRIDE_LASTMOD, "Fresh: refresh_pattern override-lastmod");
678  sum += refreshCountsStatsEntry(sentry, rc, STALE_MUST_REVALIDATE, "Stale: response has must-revalidate");
679  sum += refreshCountsStatsEntry(sentry, rc, STALE_RELOAD_INTO_IMS, "Stale: changed reload into IMS");
680  sum += refreshCountsStatsEntry(sentry, rc, STALE_FORCED_RELOAD, "Stale: request has no-cache directive");
681  sum += refreshCountsStatsEntry(sentry, rc, STALE_EXCEEDS_REQUEST_MAX_AGE_VALUE, "Stale: age exceeds request max-age value");
682  sum += refreshCountsStatsEntry(sentry, rc, STALE_EXPIRES, "Stale: expires time reached");
683  sum += refreshCountsStatsEntry(sentry, rc, STALE_MAX_RULE, "Stale: refresh_pattern max age rule");
684  sum += refreshCountsStatsEntry(sentry, rc, STALE_LMFACTOR_RULE, "Stale: refresh_pattern last-mod factor percentage");
685  sum += refreshCountsStatsEntry(sentry, rc, STALE_DEFAULT, "Stale: by default");
686  storeAppendPrintf(sentry, "\n");
687 }
688 
689 static void
691 {
692  // display per-rule counts of usage and tests
693  storeAppendPrintf(sentry, "\nRefresh pattern usage:\n\n");
694  storeAppendPrintf(sentry, " Used \tChecks \t%% Matches\tPattern\n");
695  for (const RefreshPattern *R = Config.Refresh; R; R = R->next) {
696  storeAppendPrintf(sentry, " %10" PRIu64 "\t%10" PRIu64 "\t%6.2f\t%s%s\n",
697  R->stats.matchCount,
698  R->stats.matchTests,
699  xpercent(R->stats.matchCount, R->stats.matchTests),
700  (R->pattern.flags&REG_ICASE ? "-i " : ""),
701  R->pattern.c_str());
702  }
703 
704  int i;
705  int total = 0;
706 
707  /* get total usage count */
708 
709  for (i = 0; i < rcCount; ++i)
710  total += refreshCounts[i].total;
711 
712  /* protocol usage histogram */
713  storeAppendPrintf(sentry, "\nRefreshCheck calls per protocol\n\n");
714 
715  storeAppendPrintf(sentry, "Protocol\t#Calls\t%%Calls\n");
716 
717  for (i = 0; i < rcCount; ++i)
718  storeAppendPrintf(sentry, "%10s\t%6d\t%6.2f\n",
719  refreshCounts[i].proto,
720  refreshCounts[i].total,
721  xpercent(refreshCounts[i].total, total));
722 
723  /* per protocol histograms */
724  storeAppendPrintf(sentry, "\n\nRefreshCheck histograms for various protocols\n");
725 
726  for (i = 0; i < rcCount; ++i)
727  refreshCountsStats(sentry, refreshCounts[i]);
728 }
729 
730 static void
732 {
733  Mgr::RegisterAction("refresh", "Refresh Algorithm Statistics", refreshStats, 0, 1);
734 }
735 
736 void
738 {
739  memset(refreshCounts, 0, sizeof(refreshCounts));
740  refreshCounts[rcHTTP].proto = "HTTP";
741  refreshCounts[rcICP].proto = "ICP";
742 #if USE_HTCP
743 
744  refreshCounts[rcHTCP].proto = "HTCP";
745 #endif
746 
747  refreshCounts[rcStore].proto = "On Store";
748 #if USE_CACHE_DIGESTS
749 
750  refreshCounts[rcCDigest].proto = "Cache Digests";
751 #endif
752 
754 }
755 
static OBJH refreshStats
Definition: refresh.cc:83
SQUIDCEXTERN double xpercent(double part, double whole)
Definition: util.c:54
@ FRESH_OVERRIDE_EXPIRES
Definition: refresh.cc:63
time_t timestamp
Definition: Store.h:225
time_t maxStale
Definition: SquidConfig.h:102
static int refreshCountsStatsEntry(StoreEntry *sentry, struct RefreshCounts &rc, int code, const char *desc)
Definition: refresh.cc:655
const char * storeId() const
Definition: MemObject.cc:53
@ FRESH_LMFACTOR_RULE
Definition: refresh.cc:61
MemObject * mem_obj
Definition: Store.h:222
@ FRESH_EXPIRES
Definition: refresh.cc:60
bool min
Heuristic minimum age limited.
Definition: refresh.cc:46
bool hasMinFresh(int32_t *val=nullptr) const
Definition: HttpHdrCc.h:140
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:869
int refreshCheckICP(const StoreEntry *entry, HttpRequest *request)
Definition: refresh.cc:597
struct RefreshPattern::@93 flags
Definition: SBuf.h:87
a representation of a refresh pattern.
#define PRIu64
Definition: types.h:120
int refreshCheckHTCP(const StoreEntry *entry, HttpRequest *request)
Definition: refresh.cc:608
C * getRaw() const
Definition: RefCount.h:80
uint16_t flags
Definition: Store.h:233
#define REG_ICASE
Definition: GnuRegex.h:230
@ FRESH_REQUEST_MAX_STALE_VALUE
Definition: refresh.cc:59
@ FRESH_MIN_RULE
Definition: refresh.cc:62
time_t expires
Definition: Store.h:227
time_t getMaxAge(const char *url)
Definition: refresh.cc:643
@ FRESH_OVERRIDE_LASTMOD
Definition: refresh.cc:64
const char * proto
Definition: refresh.cc:77
int refreshCheckHTTP(const StoreEntry *entry, HttpRequest *request)
Definition: refresh.cc:585
bool hasMaxStale(int32_t *val=nullptr) const
Definition: HttpHdrCc.h:132
@ STALE_MAX_RULE
Definition: refresh.cc:70
@ rcICP
Definition: refresh.cc:30
@ STALE_EXPIRES
Definition: refresh.cc:69
static void refreshCountsStats(StoreEntry *sentry, struct RefreshCounts &rc)
Definition: refresh.cc:662
static const int32_t MAX_STALE_ANY
Definition: HttpHdrCc.h:53
RefreshPattern * Refresh
Definition: SquidConfig.h:428
@ STALE_EXCEEDS_REQUEST_MAX_AGE_VALUE
Definition: refresh.cc:68
void OBJH(StoreEntry *)
Definition: forward.h:44
#define NULL
Definition: types.h:166
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
static struct RefreshCounts refreshCounts[rcCount]
const HttpReply & baseReply() const
Definition: MemObject.h:59
static const RefreshPattern * refreshUncompiledPattern(const char *)
Definition: refresh.cc:115
const RefreshPattern * refreshLimits(const char *url)
Definition: refresh.cc:93
refreshCountsEnum
Definition: refresh.cc:28
static void refreshRegisterWithCacheManager(void)
Definition: refresh.cc:731
#define EBIT_TEST(flag, bit)
Definition: defines.h:69
unsigned char code
Definition: html_quote.c:20
@ STALE_MUST_REVALIDATE
Definition: refresh.cc:65
#define REFRESH_DEFAULT_MAX
static RefreshPattern DefaultRefresh("<none>", 0)
const char * c_str() const
Definition: RegexPattern.h:35
#define assert(EX)
Definition: assert.h:19
@ STALE_RELOAD_INTO_IMS
Definition: refresh.cc:66
bool expires
Expires: header absolute timestamp limit.
Definition: refresh.cc:45
int refresh_all_ims
Definition: SquidConfig.h:297
@ STALE_DEFAULT
Definition: refresh.cc:73
const char * c_str()
Definition: SBuf.cc:516
time_t squid_curtime
Definition: stub_time.cc:17
static int refreshCheck(const StoreEntry *entry, HttpRequest *request, time_t delta)
Definition: refresh.cc:265
int64_t content_length
Definition: Message.h:84
const char * mkrfc1123(time_t)
Definition: rfc1123.c:202
@ STALE_LMFACTOR_RULE
Definition: refresh.cc:71
void refreshInit(void)
Definition: refresh.cc:737
int status[STALE_DEFAULT+1]
Definition: refresh.cc:79
@ rcHTCP
Definition: refresh.cc:32
@ rcCDigest
Definition: refresh.cc:35
@ STALE_FORCED_RELOAD
Definition: refresh.cc:67
struct SquidConfig::@111 onoff
static int refreshStaleness(const StoreEntry *entry, time_t check_time, const time_t age, const RefreshPattern *R, stale_flags *sf)
Definition: refresh.cc:147
static bool refreshIsStaleIfHit(const int reason)
whether reply is stale if it is a hit
Definition: refresh.cc:564
bool hasMaxAge(int32_t *val=nullptr) const
Definition: HttpHdrCc.h:122
int reload_into_ims
Definition: SquidConfig.h:300
bool refreshIsCachable(const StoreEntry *entry)
Definition: refresh.cc:529
int refreshCheckDigest(const StoreEntry *entry, time_t delta)
Definition: refresh.cc:621
time_t minimum_expiry_time
Definition: SquidConfig.h:519
void lastModified(const time_t when)
Definition: Store.h:177
@ rcStore
Definition: refresh.cc:37
@ ENTRY_REVALIDATE_STALE
Definition: enums.h:100
@ ENTRY_REVALIDATE_ALWAYS
Definition: enums.h:85
@ FRESH_REQUEST_MAX_STALE_ALL
Definition: refresh.cc:58
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
Definition: Registration.cc:16
bool lmfactor
Last-Modified with heuristic determines limit.
Definition: refresh.cc:47
@ rcCount
Definition: refresh.cc:38
RefreshPattern * next
RegexPattern pattern
A const & min(A const &lhs, A const &rhs)
const HttpReply * hasFreshestReply() const
Definition: Store.h:58
bool max
Configured maximum age limit.
Definition: refresh.cc:48
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
HttpRequestPointer request
Definition: MemObject.h:188
@ STALE_MAX_STALE
Definition: refresh.cc:72
class SquidConfig Config
Definition: SquidConfig.cc:12
@ rcHTTP
Definition: refresh.cc:29

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors