You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2009/10/05 22:27:19 UTC

svn commit: r821993 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/mod_cache.xml modules/cache/mod_cache.c

Author: minfrin
Date: Mon Oct  5 20:27:19 2009
New Revision: 821993

URL: http://svn.apache.org/viewvc?rev=821993&view=rev
Log:
mod_cache: Teach CacheEnable and CacheDisable to work from within a
Location section, in line with how ProxyPass works.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/docs/manual/mod/mod_cache.xml
    httpd/httpd/trunk/modules/cache/mod_cache.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=821993&r1=821992&r2=821993&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Oct  5 20:27:19 2009
@@ -10,6 +10,9 @@
      mod_proxy_ftp: NULL pointer dereference on error paths.
      [Stefan Fritsch <sf fritsch.de>, Joe Orton]
 
+  *) mod_cache: Teach CacheEnable and CacheDisable to work from within a
+     Location section, in line with how ProxyPass works. [Graham Leggett]
+
   *) mod_reqtimeout: New module to set timeouts and minimum data rates for
      receiving requests from the client. [Stefan Fritsch]
 

Modified: httpd/httpd/trunk/docs/manual/mod/mod_cache.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_cache.xml?rev=821993&r1=821992&r2=821993&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_cache.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_cache.xml Mon Oct  5 20:27:19 2009
@@ -238,7 +238,9 @@
     <p>The <directive>CacheEnable</directive> directive instructs
     <module>mod_cache</module> to cache urls at or below
     <var>url-string</var>. The cache storage manager is specified with the
-    <var>cache_type</var> argument. 
+    <var>cache_type</var> argument. If the <directive>CacheEnable</directive>
+    directive is placed inside a <directive type="section">Location</directive>
+    directive, the <var>url-string</var> becomes optional.
     <var>cache_type</var> <code>disk</code> instructs
     <module>mod_cache</module> to use the disk based storage manager
     implemented by <module>mod_disk_cache</module>.</p>
@@ -284,7 +286,7 @@
 <directivesynopsis>
 <name>CacheDisable</name>
 <description>Disable caching of specified URLs</description>
-<syntax>CacheDisable <var> url-string</var></syntax>
+<syntax>CacheDisable <var>url-string</var> | <var>on</var></syntax>
 <contextlist><context>server config</context><context>virtual host</context>
 </contextlist>
 
@@ -297,6 +299,16 @@
       CacheDisable /local_files
     </example>
 
+    <p>If used in a <directive type="section">Location</directive> directive,
+    the path needs to be specified below the Location, or if the word "on"
+    is used, caching for the whole location will be disabled.</p>
+
+    <example><title>Example</title>
+      &lt;Location /foo&gt;<br />
+        CacheDisable on<br />
+      &lt;/Location&gt;<br />
+    </example>
+
     <p> The <code>no-cache</code> environment variable can be set to 
     disable caching on a finer grained set of resources in versions
     2.2.12 and later.</p>

Modified: httpd/httpd/trunk/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.c?rev=821993&r1=821992&r2=821993&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.c Mon Oct  5 20:27:19 2009
@@ -1516,12 +1516,30 @@
     cache_server_conf *conf;
     struct cache_enable *new;
 
+    const char *err = ap_check_cmd_context(parms,
+                                           NOT_IN_DIRECTORY|NOT_IN_LIMIT|NOT_IN_FILES);
+    if (err != NULL) {
+        return err;
+    }
+
     if (*type == '/') {
         return apr_psprintf(parms->pool,
           "provider (%s) starts with a '/'.  Are url and provider switched?",
           type);
     }
 
+    if (!url) {
+        url = parms->path;
+    }
+    if (!url) {
+        return apr_psprintf(parms->pool,
+          "CacheEnable provider (%s) is missing an URL.", type);
+    }
+    if (parms->path && strncmp(parms->path, url, strlen(parms->path))) {
+        return "When in a Location, CacheEnable must specify a path or an URL below "
+        "that location.";
+    }
+
     conf =
         (cache_server_conf *)ap_get_module_config(parms->server->module_config,
                                                   &cache_module);
@@ -1545,6 +1563,25 @@
     cache_server_conf *conf;
     struct cache_disable *new;
 
+    const char *err = ap_check_cmd_context(parms,
+                                           NOT_IN_DIRECTORY|NOT_IN_LIMIT|NOT_IN_FILES);
+    if (err != NULL) {
+        return err;
+    }
+
+    if (parms->path && !strcmp(url, "on")) {
+        url = parms->path;
+    }
+    if (url[0] != '/' && !strchr(url, ':')) {
+        return "CacheDisable must specify a path or an URL, or when in a Location, "
+            "the word 'on'.";
+    }
+
+    if (parms->path && strncmp(parms->path, url, strlen(parms->path))) {
+        return "When in a Location, CacheDisable must specify a path or an URL below "
+        "that location.";
+    }
+
     conf =
         (cache_server_conf *)ap_get_module_config(parms->server->module_config,
                                                   &cache_module);
@@ -1704,10 +1741,10 @@
      * This is more intuitive that requiring a LoadModule directive.
      */
 
-    AP_INIT_TAKE2("CacheEnable", add_cache_enable, NULL, RSRC_CONF,
-                  "A cache type and partial URL prefix below which "
-                  "caching is enabled"),
-    AP_INIT_TAKE1("CacheDisable", add_cache_disable, NULL, RSRC_CONF,
+    AP_INIT_TAKE12("CacheEnable", add_cache_enable, NULL, RSRC_CONF|ACCESS_CONF,
+                   "A cache type and partial URL prefix below which "
+                   "caching is enabled"),
+    AP_INIT_TAKE1("CacheDisable", add_cache_disable, NULL, RSRC_CONF|ACCESS_CONF,
                   "A partial URL prefix below which caching is disabled"),
     AP_INIT_TAKE1("CacheMaxExpire", set_cache_maxex, NULL, RSRC_CONF,
                   "The maximum time in seconds to cache a document"),



Re: svn commit: r821993 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/mod_cache.xml modules/cache/mod_cache.c

Posted by Graham Leggett <mi...@sharp.fm>.
Ruediger Pluem wrote:

> It should be noted that this doesn't work with regular expressions / LocationMatch.

True, let me take a closer look.

Regards,
Graham
--

Re: svn commit: r821993 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/mod_cache.xml modules/cache/mod_cache.c

Posted by Ruediger Pluem <rp...@apache.org>.

On 10/05/2009 10:27 PM, minfrin@apache.org wrote:
> Author: minfrin
> Date: Mon Oct  5 20:27:19 2009
> New Revision: 821993
> 
> URL: http://svn.apache.org/viewvc?rev=821993&view=rev
> Log:
> mod_cache: Teach CacheEnable and CacheDisable to work from within a
> Location section, in line with how ProxyPass works.
> 
> Modified:
>     httpd/httpd/trunk/CHANGES
>     httpd/httpd/trunk/docs/manual/mod/mod_cache.xml
>     httpd/httpd/trunk/modules/cache/mod_cache.c
> 
> Modified: httpd/httpd/trunk/CHANGES
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=821993&r1=821992&r2=821993&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/CHANGES [utf-8] (original)
> +++ httpd/httpd/trunk/CHANGES [utf-8] Mon Oct  5 20:27:19 2009
> @@ -10,6 +10,9 @@
>       mod_proxy_ftp: NULL pointer dereference on error paths.
>       [Stefan Fritsch <sf fritsch.de>, Joe Orton]
>  
> +  *) mod_cache: Teach CacheEnable and CacheDisable to work from within a
> +     Location section, in line with how ProxyPass works. [Graham Leggett]

It should be noted that this doesn't work with regular expressions / LocationMatch.

Regards

RĂ¼diger