You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Solo Luke <so...@gmail.com> on 2014/08/06 10:56:34 UTC

[users@httpd] Apache 2.4 memcached module not caching

Hi I did this configuration:

<IfModule cache_module>

      <IfModule cache_socache_module>
            CacheSocache memcache:localhost:11211
            CacheSocacheMaxSize 512000
            CacheSocacheMaxTime 86400

                 <Location /api>
                       CacheEnable memcache /
                  </Location>

          </IfModule>

</IfModule>

Unfortunately the memcache module does not cache the response in memcached
server. What is wrong?

I want that after first request-response the Apache to cache to server
response in memcached and feature requests to be fetched from memcached.

Is this configuration doing what I want?

I checked the memcached keys but no key is inserted.

Kind regards,
Danny

Re: [users@httpd] Apache 2.4 memcached module not caching

Posted by Solo Luke <so...@gmail.com>.
Final configuration look like this:

LoadModule cache_module modules/mod_cache.so
LoadModule cache_socache_module modules/mod_cache_socache.so
LoadModule socache_memcache_module modules/mod_socache_memcache.so

# Enable cache for /api folder from root /var/www/html/api
CacheEnable socache /api
# Connect to memcached server
 CacheSocache memcache:localhost:11211
# Few more options
 CacheSocacheMaxSize 512000
 CacheSocacheMaxTime 86400

Checked with httpd -M and modules are loaded.

I've checked (lsof | grep cache). The following modules are loaded:

httpd       443  2740         apache  mem       REG                8,2
11176    2492656 /usr/lib64/httpd/modules/mod_socache_memcache.so

httpd       443  2740         apache  mem       REG                8,2
77352    2492592 /usr/lib64/httpd/modules/mod_cache.so

I removed the IfModule and no error appears.

Memcached statisctics with telnet:

telnet 127.0.0.1 11211
stats

STAT cmd_get 131
STAT cmd_set 2

Apache log:


[Thu Aug 07 11:24:47.429792 2014] [core:trace5] [pid 2611:tid
140526816745216] protocol.c(618): [client 192.168.1.40:40952] Request
received from client: GET /api/1.jpg HTTP/1.0
[Thu Aug 07 11:24:47.429828 2014] [http:trace4] [pid 2611:tid
140526816745216] http_request.c(301): [client 192.168.1.40:40952] Headers
received from client:
[Thu Aug 07 11:24:47.429831 2014] [http:trace4] [pid 2611:tid
140526816745216] http_request.c(305): [client 192.168.1.40:40952]   Host:
192.168.1.127
[Thu Aug 07 11:24:47.429833 2014] [http:trace4] [pid 2611:tid
140526816745216] http_request.c(305): [client 192.168.1.40:40952]
User-Agent: ApacheBench/2.3
[Thu Aug 07 11:24:47.429835 2014] [http:trace4] [pid 2611:tid
140526816745216] http_request.c(305): [client 192.168.1.40:40952]   Accept:
*/*
[Thu Aug 07 11:24:47.429844 2014] [cache:debug] [pid 2611:tid
140526816745216] cache_storage.c(664): [client 192.168.1.40:40952] AH00698:
cache: Key for entity /api/1.jpg?(null) is http://192.168.1.127:80/api/1.jpg
?
[Thu Aug 07 11:24:47.430332 2014] [cache:debug] [pid 2611:tid
140526816745216] mod_cache.c(636): [client 192.168.1.40:40952] AH00763:
cache: running CACHE_OUT filter
[Thu Aug 07 11:24:47.430339 2014] [cache:debug] [pid 2611:tid
140526816745216] mod_cache.c(665): [client 192.168.1.40:40952] AH00764:
cache: serving /api/1.jpg
[Thu Aug 07 11:24:47.430368 2014] [http:trace3] [pid 2611:tid
140526816745216] http_filters.c(963): [client 192.168.1.40:40952] Response
sent with status 200, headers:
[Thu Aug 07 11:24:47.430371 2014] [http:trace5] [pid 2611:tid
140526816745216] http_filters.c(970): [client 192.168.1.40:40952]   Date:
Thu, 07 Aug 2014 08:24:47 GMT
[Thu Aug 07 11:24:47.430372 2014] [http:trace5] [pid 2611:tid
140526816745216] http_filters.c(973): [client 192.168.1.40:40952]   Server:
Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.30
[Thu Aug 07 11:24:47.430374 2014] [http:trace4] [pid 2611:tid
140526816745216] http_filters.c(806): [client 192.168.1.40:40952]
Last-Modified: Mon, 04 Aug 2014 15:08:06 GMT
[Thu Aug 07 11:24:47.430384 2014] [http:trace4] [pid 2611:tid
140526816745216] http_filters.c(806): [client 192.168.1.40:40952]   ETag:
\\"1c7bd-4ffcf1b2ba180\\"
[Thu Aug 07 11:24:47.430386 2014] [http:trace4] [pid 2611:tid
140526816745216] http_filters.c(806): [client 192.168.1.40:40952]
Accept-Ranges: bytes
[Thu Aug 07 11:24:47.430388 2014] [http:trace4] [pid 2611:tid
140526816745216] http_filters.c(806): [client 192.168.1.40:40952]
Content-Length: 116669
[Thu Aug 07 11:24:47.430389 2014] [http:trace4] [pid 2611:tid
140526816745216] http_filters.c(806): [client 192.168.1.40:40952]   Age: 204
[Thu Aug 07 11:24:47.430391 2014] [http:trace4] [pid 2611:tid
140526816745216] http_filters.c(806): [client 192.168.1.40:40952]
Connection: close
[Thu Aug 07 11:24:47.430393 2014] [http:trace4] [pid 2611:tid
140526816745216] http_filters.c(806): [client 192.168.1.40:40952]
Content-Type: image/jpeg

This is a basic configuration for static content caching with memcached and
work wonderful.

Thank you!


On Wed, Aug 6, 2014 at 5:37 PM, Eric Covener <co...@gmail.com> wrote:

> On Wed, Aug 6, 2014 at 10:28 AM, Solo Luke <so...@gmail.com> wrote:
> > I removed IfModule and I get errors.
>
> That's the point. You need to load modules you want used.
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Apache 2.4 memcached module not caching

Posted by Eric Covener <co...@gmail.com>.
On Wed, Aug 6, 2014 at 10:28 AM, Solo Luke <so...@gmail.com> wrote:
> I removed IfModule and I get errors.

That's the point. You need to load modules you want used.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Apache 2.4 memcached module not caching

Posted by Solo Luke <so...@gmail.com>.
Did that but nothing in the error log.

Here is what I have in logs:

[Wed Aug 06 17:08:49.217652 2014] [core:trace5] [pid 28059:tid
140264647657216] protocol.c(618): [client 192.168.1.113:7899] Request
received from client: GET /api/1.jpg HTTP/1.1
[Wed Aug 06 17:08:49.217723 2014] [http:trace4] [pid 28059:tid
140264647657216] http_request.c(301): [client 192.168.1.113:7899] Headers
received from client:
[Wed Aug 06 17:08:49.217728 2014] [http:trace4] [pid 28059:tid
140264647657216] http_request.c(305): [client 192.168.1.113:7899]   Host:
192.168.1.127
[Wed Aug 06 17:08:49.217731 2014] [http:trace4] [pid 28059:tid
140264647657216] http_request.c(305): [client 192.168.1.113:7899]
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101
Firefox/31.0
[Wed Aug 06 17:08:49.217733 2014] [http:trace4] [pid 28059:tid
140264647657216] http_request.c(305): [client 192.168.1.113:7899]   Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[Wed Aug 06 17:08:49.217735 2014] [http:trace4] [pid 28059:tid
140264647657216] http_request.c(305): [client 192.168.1.113:7899]
Accept-Language: en-US,en;q=0.5
[Wed Aug 06 17:08:49.217737 2014] [http:trace4] [pid 28059:tid
140264647657216] http_request.c(305): [client 192.168.1.113:7899]
Accept-Encoding: gzip, deflate
[Wed Aug 06 17:08:49.217763 2014] [http:trace4] [pid 28059:tid
140264647657216] http_request.c(305): [client 192.168.1.113:7899]   DNT: 1
[Wed Aug 06 17:08:49.217766 2014] [http:trace4] [pid 28059:tid
140264647657216] http_request.c(305): [client 192.168.1.113:7899]
X-ClickOnceSupport: ( .NET CLR 3.5.30729; .NET4.0E)
[Wed Aug 06 17:08:49.217768 2014] [http:trace4] [pid 28059:tid
140264647657216] http_request.c(305): [client 192.168.1.113:7899]
Connection: keep-alive
[Wed Aug 06 17:08:49.217770 2014] [http:trace4] [pid 28059:tid
140264647657216] http_request.c(305): [client 192.168.1.113:7899]
If-Modified-Since: Mon, 04 Aug 2014 15:08:06 GMT
[Wed Aug 06 17:08:49.217772 2014] [http:trace4] [pid 28059:tid
140264647657216] http_request.c(305): [client 192.168.1.113:7899]
If-None-Match: \\"1c7bd-4ffcf1b2ba180\\"
[Wed Aug 06 17:08:49.217774 2014] [http:trace4] [pid 28059:tid
140264647657216] http_request.c(305): [client 192.168.1.113:7899]
Cache-Control: max-age=0
[Wed Aug 06 17:08:49.217810 2014] [authz_core:debug] [pid 28059:tid
140264647657216] mod_authz_core.c(802): [client 192.168.1.113:7899]
AH01626: authorization result of Require all granted: granted
[Wed Aug 06 17:08:49.217828 2014] [authz_core:debug] [pid 28059:tid
140264647657216] mod_authz_core.c(802): [client 192.168.1.113:7899]
AH01626: authorization result of <RequireAny>: granted
[Wed Aug 06 17:08:49.217832 2014] [core:trace3] [pid 28059:tid
140264647657216] request.c(238): [client 192.168.1.113:7899] request
authorized without authentication by access_checker_ex hook: /api/1.jpg
[Wed Aug 06 17:08:49.218903 2014] [http:trace3] [pid 28059:tid
140264647657216] http_filters.c(963): [client 192.168.1.113:7899] Response
sent with status 304, headers:
[Wed Aug 06 17:08:49.218923 2014] [http:trace5] [pid 28059:tid
140264647657216] http_filters.c(970): [client 192.168.1.113:7899]   Date:
Wed, 06 Aug 2014 14:08:49 GMT
[Wed Aug 06 17:08:49.218927 2014] [http:trace5] [pid 28059:tid
140264647657216] http_filters.c(973): [client 192.168.1.113:7899]   Server:
Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.30


<IfModule cache_module>
    <IfModule cache_socache_module>
         CacheSocache memcache:localhost:11211
         CacheSocacheMaxSize 512000
         CacheSocacheMaxTime 86400
           <Location /api>
               CacheEnable memcache
           </Location>
     </IfModule>
</IfModule>

I removed IfModule and I get errors.



On Wed, Aug 6, 2014 at 2:06 PM, Eric Covener <co...@gmail.com> wrote:

> On Wed, Aug 6, 2014 at 4:56 AM, Solo Luke <so...@gmail.com> wrote:
> > Unfortunately the memcache module does not cache the response in
> memcached
> > server. What is wrong?
>
>
> Try removing all of the ifModule directives as a start.  Then set
> loglevel trace8 and have a look at the logs.
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Apache 2.4 memcached module not caching

Posted by Eric Covener <co...@gmail.com>.
On Wed, Aug 6, 2014 at 4:56 AM, Solo Luke <so...@gmail.com> wrote:
> Unfortunately the memcache module does not cache the response in memcached
> server. What is wrong?


Try removing all of the ifModule directives as a start.  Then set
loglevel trace8 and have a look at the logs.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org