Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _CACHE_CONTROL_H_
00032 #define _CACHE_CONTROL_H_
00033
00034 #include "Main.h"
00035 #include "P_EventSystem.h"
00036 #include "ControlBase.h"
00037
00038 struct RequestData;
00039
00040 const int CC_UNSET_TIME = -1;
00041
00042 #define CACHE_CONTROL_TIMEOUT (HRTIME_HOUR*1)
00043
00044
00045
00046
00047
00048 enum CacheControlType
00049 {
00050 CC_INVALID = 0,
00051 CC_REVALIDATE_AFTER,
00052 CC_NEVER_CACHE,
00053 CC_STANDARD_CACHE,
00054 CC_IGNORE_NO_CACHE,
00055 CC_CLUSTER_CACHE_LOCAL,
00056 CC_IGNORE_CLIENT_NO_CACHE,
00057 CC_IGNORE_SERVER_NO_CACHE,
00058 CC_PIN_IN_CACHE,
00059 CC_TTL_IN_CACHE,
00060 CC_NUM_TYPES
00061 };
00062
00063 struct matcher_line;
00064
00065 class CacheControlResult
00066 {
00067 public:
00068
00069 inkcoreapi CacheControlResult();
00070 void Print();
00071
00072
00073
00074
00075
00076 int revalidate_after;
00077 int pin_in_cache_for;
00078 int ttl_in_cache;
00079 bool never_cache;
00080 bool cluster_cache_local;
00081 bool ignore_client_no_cache;
00082 bool ignore_server_no_cache;
00083 bool ignore_client_cc_max_age;
00084 int cache_responses_to_cookies;
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 int reval_line;
00095 int never_line;
00096 int pin_line;
00097 int ttl_line;
00098 int cluster_cache_local_line;
00099 int ignore_client_line;
00100 int ignore_server_line;
00101 };
00102
00103 inline
00104 CacheControlResult::CacheControlResult()
00105 : revalidate_after(CC_UNSET_TIME),
00106 pin_in_cache_for(CC_UNSET_TIME),
00107 ttl_in_cache(CC_UNSET_TIME),
00108 never_cache(false),
00109 cluster_cache_local(false),
00110 ignore_client_no_cache(false),
00111 ignore_server_no_cache(false),
00112 ignore_client_cc_max_age(true),
00113 cache_responses_to_cookies(-1),
00114 reval_line(-1),
00115 never_line(-1),
00116 pin_line(-1),
00117 ttl_line(-1),
00118 cluster_cache_local_line(-1),
00119 ignore_client_line(-1),
00120 ignore_server_line(-1)
00121 { }
00122
00123 class CacheControlRecord : public ControlBase
00124 {
00125 public:
00126 CacheControlRecord();
00127 CacheControlType directive;
00128 int time_arg;
00129 int cache_responses_to_cookies;
00130 char *Init(matcher_line * line_info);
00131 inkcoreapi void UpdateMatch(CacheControlResult * result, RequestData * rdata);
00132 void Print();
00133 };
00134
00135 inline
00136 CacheControlRecord::CacheControlRecord()
00137 : ControlBase(), directive(CC_INVALID), time_arg(0) , cache_responses_to_cookies(-1)
00138 { }
00139
00140
00141
00142
00143 class URL;
00144 struct HttpConfigParams;
00145 struct OverridableHttpConfigParams;
00146
00147 inkcoreapi void getCacheControl(CacheControlResult *result, HttpRequestData * rdata,
00148 OverridableHttpConfigParams *h_txn_conf, char *tag = NULL);
00149 inkcoreapi bool getClusterCacheLocal(URL *url, char *hostname);
00150 inkcoreapi bool host_rule_in_CacheControlTable();
00151 inkcoreapi bool ip_rule_in_CacheControlTable();
00152
00153 void initCacheControl();
00154 void reloadCacheControl();
00155
00156 #endif