You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by st...@apache.org on 2002/02/02 17:20:33 UTC

cvs commit: httpd-2.0/modules/experimental mod_cache.c

stoddard    02/02/02 08:20:33

  Modified:    modules/experimental mod_cache.c
  Log:
  Add a few more checks to determine a response should be cached.
  
  Revision  Changes    Path
  1.22      +15 -5     httpd-2.0/modules/experimental/mod_cache.c
  
  Index: mod_cache.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- mod_cache.c	30 Jan 2002 18:53:33 -0000	1.21
  +++ mod_cache.c	2 Feb 2002 16:20:33 -0000	1.22
  @@ -84,7 +84,7 @@
   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 @@
        */
   
       /* 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 @@
        * 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);