• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

CacheControl.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 /*****************************************************************************
00025  *
00026  *  CacheControl.h - Interface to Cache Control systtem
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 //   Use 10 second time for purify testing under low
00045 //     load to verify memory allocation
00046 //#define CACHE_CONTROL_TIMEOUT            (HRTIME_SECOND*10)
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   // Data for external use
00073   //
00074   //   Describes the cache-control for a specific URL
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; ///< Override for caching cookied responses.
00085 
00086   // Data for internal use only
00087   //
00088   //   Keeps track of the last line number
00089   //    on which a parameter was set
00090   //   Used to tell if a parameter needs to
00091   //    be overriden by something that appeared
00092   //    earlier in the the config file
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), // do not change value
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 // API to outside world
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 /* _CACHE_CONTROL_H_ */

Generated by  doxygen 1.7.1