]> granicus.if.org Git - apache/commitdiff
Add a few more checks to determine a response should be cached.
authorBill Stoddard <stoddard@apache.org>
Sat, 2 Feb 2002 16:20:33 +0000 (16:20 +0000)
committerBill Stoddard <stoddard@apache.org>
Sat, 2 Feb 2002 16:20:33 +0000 (16:20 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93181 13f79535-47bb-0310-9956-ffa450edef68

modules/experimental/mod_cache.c

index 1e146ce6d2b87df3ceff84a9402e098ea8085fd1..8bd2986c3b2df56d5f760d356556bb2c33f9be35 100644 (file)
@@ -84,7 +84,7 @@ module AP_MODULE_DECLARE_DATA cache_module;
 static int cache_url_handler(request_rec *r)
 {
     apr_status_t rv;
-    const char *cc_in;
+    const char *cc_in, *pragma, *auth;
     apr_uri_t uri = r->parsed_uri;
     char *url = r->unparsed_uri;
     char *path = uri.path;
@@ -123,7 +123,9 @@ static int cache_url_handler(request_rec *r)
      */
 
     /* find certain cache controlling headers */
-    cc_in = ap_table_get(r->headers_in, "Cache-Control");
+    cc_in = apr_table_get(r->headers_in, "Cache-Control");
+    pragma = apr_table_get(r->headers_in, "Pragma");
+    auth = apr_table_get(r->headers_in, "Authorization");
 
     /* first things first - does the request allow us to return
      * cached information at all? If not, just decline the request.
@@ -135,10 +137,18 @@ static int cache_url_handler(request_rec *r)
      * Caching is forbidden under the following circumstances:
      *
      * - RFC2616 14.9.2 Cache-Control: no-store
-     * we are not supposed to store this request at all. Behave as a
-     * tunnel.
+     * - Pragma: no-cache
+     * - Any requests requiring authorization.
+     * - Any URLs whose length exceeds MAX_URL_LENGTH
+     * - TODO: Make MAX_URL_LENGTH a config directive?
      */
-    if (ap_cache_liststr(cc_in, "no-store", NULL)) {
+    if (strlen(url) > MAX_URL_LENGTH) {
+        ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
+                     "cache: URL exceeds length threshold: %s", url);
+        return DECLINED;
+    }
+    if (ap_cache_liststr(cc_in, "no-store", NULL) ||
+        ap_cache_liststr(pragma, "no-cache", NULL) || (auth != NULL)) {
         /* delete the previously cached file */
         cache_remove_url(r, cache->types, url);