Hi,
My svn account is created now, and I have commited mod-cache-requester files.
http://svn.apache.org/repos/asf/httpd/mod_cache_requester/
Along with these files, I had to make some changes in mod_cache.c,
mod_cache.h and config.m4 as well. I am attaching patches for all
three files with this mail.
in mod_cache.h I have added declaration of cache_requester data structure.
+#define CACHE_REQUESTER_PROVIDER_GROUP "cache_requester"
+typedef struct {
+ int (*notify_cache_requester) (request_rec *r, cache_handle_t *handle);
+} cache_req_provider;
+
- in mod_cache.c I have added code for calling mod_cache_requester if
the page is 'soon-to-expire'
+ cache_req_provider *cache_requester;
+ char *is_from_cache_requester;
+ cache_handle_t *handle;
+
+ cache_requester = (cache_req_provider *)
ap_lookup_provider(CACHE_REQUESTER_PROVIDER_GROUP, "cache_req", "0");
+ if(cache_requester != NULL) {
+ if( cache_requester->notify_cache_requester(r, cache->handle)
== DECLINED) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
+ "Adding CACHE_SAVE filter.");
+ ap_add_output_filter_handle(cache_save_filter_handle, NULL, r,
+ r->connection);
+ return DECLINED;
+ }
+ }
- config.m4 of mod_cache required modification to add mod_cache_requester.
Please have a look at the code availabe in repository and patches
attached with this mail and let me know your thoughts. all your
suggestions/corrections are welcome!
Currently, mod-cache-requester has dependency on libcurl. basically,
mod-cache-requester has to make a request for a page to refresh cache,
and it seems there is no straight forward way to do so if you dont
have connection available. thats why we had to use libcurl instead.
so as a next step, I am planning to investigate more about how to get
rid of libcurl from the code. any pointers in that direction would be
really helpful.
Thanks,
Parin.
--- old_mod_cache.h 2006-02-18 19:09:07.000000000 -0600
+++ mod_cache.h 2006-02-23 22:41:00.000000000 -0600
@@ -229,6 +229,16 @@
cache_provider_list *next;
};
+
+// Provider structure. methods of this structure are used by the mod-cache's quick handler to insert soon-to-expire pages into the queue.
+
+#define CACHE_REQUESTER_PROVIDER_GROUP "cache_requester"
+
+typedef struct {
+ int (*notify_cache_requester) (request_rec *r, cache_handle_t *handle);
+} cache_req_provider;
+
+
/* per request cache information */
typedef struct {
cache_provider_list *providers; /* possible cache providers */
--- old_mod_cache.c 2006-02-18 19:09:07.000000000 -0600
+++ mod_cache.c 2006-02-23 22:37:09.000000000 -0600
@@ -57,6 +57,10 @@
cache_server_conf *conf;
apr_bucket_brigade *out;
+ cache_req_provider *cache_requester;
+ char *is_from_cache_requester;
+ cache_handle_t *handle;
+
/* Delay initialization until we know we are handling a GET */
if (r->method_number != M_GET) {
return DECLINED;
@@ -169,6 +173,18 @@
return DECLINED;
}
+ cache_requester = (cache_req_provider *) ap_lookup_provider(CACHE_REQUESTER_PROVIDER_GROUP, "cache_req", "0");
+ if(cache_requester != NULL) {
+ if( cache_requester->notify_cache_requester(r, cache->handle) == DECLINED) {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
+ "Adding CACHE_SAVE filter.");
+ ap_add_output_filter_handle(cache_save_filter_handle, NULL, r,
+ r->connection);
+ return DECLINED;
+ }
+ }
+
+
/* if we are a lookup, we are exiting soon one way or another; Restore
* the headers. */
if (lookup) {
--- ol-config.m4 2006-02-23 22:44:30.000000000 -0600
+++ config.m4 2005-08-24 00:12:27.000000000 -0500
@@ -6,6 +6,7 @@
APACHE_MODULE(file_cache, File cache, , , no)
+
dnl # list of object files for mod_cache
cache_objs="dnl
mod_cache.lo dnl
@@ -19,8 +20,18 @@
cache_pqueue.lo dnl
cache_hash.lo dnl
"
+
+cache_requester_objs="dnl
+mod_cache_requester.lo dnl
+"
+
APACHE_MODULE(cache, dynamic file caching, $cache_objs, , no)
APACHE_MODULE(disk_cache, disk caching module, , , no)
APACHE_MODULE(mem_cache, memory caching module, $mem_cache_objs, , no)
+APACHE_MODULE(cache_requester, cache requester module, $cache_requester_objs, , no)
+
+ if test "enable_cache_requester" != "no"; then
+ APR_ADDTO(LDFLAGS, [`curl-config --libs`])
+ fi
APACHE_MODPATH_FINISH