# Question about memcache

**URL:** <https://www.ruby-forum.com/t/question-about-memcache/206075>\
**Category:** NGINX\
**Created:** [April 21, 2011, 8:32pm UTC](https://www.ruby-forum.com/t/question-about-memcache/206075 "2011-04-21T20:32:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 21, 2011, 8:32pm UTC](https://www.ruby-forum.com/t/question-about-memcache/206075/1 "2011-04-21T20:32:56Z")

</div>

Hello,  
I am trying to add memcache module in Nginx.

Following  
[http://wiki.nginx.org/NginxHttpMemcachedModule](http://wiki.nginx.org/NginxHttpMemcachedModule)

> **[speeding up your nginx server with memcached](http://lserinol.blogspot.com/2009/03/speeding-up-your-nginx-server-with.html)**
>
> Nginx is a high performance web and proxy (web and mail proxy) server. Generally, nginx is used as a front-end proxy server to Apache web...

In Levent’s blog, in the end, he mentioned

"Nginx’s memcache module never put anything automatically in memcached.  
You have to store your information in it manually by using something  
like a script. Considering our example, if we forget to store  
information about a file in memcached, it will be always served by  
back-end Apache servers. Here is a simple php script, which finds given  
image types and deploy it into memcached for Nginx. "

I want to know whether it is still valid? Since the blog is one year  
ago. Maybe Nginx improve memcache module in the middle.

For dynamically generate webpage on the backend server (query mysql  
database), I do not have static files. So how can I use memcache to  
record dynamically created webpage in front server? (Nginx frontend  
server is running in 192.168.2.1, and backend server running in  
192.168.2.2)

Thanks,  
Yanxin

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [April 21, 2011, 8:56pm UTC](https://www.ruby-forum.com/t/question-about-memcache/206075/2 "2011-04-21T20:56:03Z")

</div>

On 21 Abr 2011 19h32 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> using something like a script. Considering our example, if we forget  
> to store information about a file in memcached, it will be always  
> served by back-end Apache servers. Here is a simple php script,  
> which finds given image types and deploy it into memcached for  
> Nginx. "
> 
> I want to know whether it is still valid? Since the blog is one year  
> ago. Maybe Nginx improve memcache module in the middle.

AFAIK it’ still the case: the nginx memcache official module is a  
write only thing. you can however use agentzh’s memc module that  
supports also writing and more:

> **[GitHub - openresty/memc-nginx-module: An extended version of the standard memcached...](https://github.com/openresty/memc-nginx-module)**
>
> An extended version of the standard memcached module that supports set, add, delete, and many more memcached commands.

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

> For dynamically generate webpage on the backend server (query mysql  
> database), I do not have static files. So how can I use memcache to  
> record dynamically created webpage in front server? (Nginx frontend  
> server is running in 192.168.2.1, and backend server running in  
> 192.168.2.2)

See above.

— appa

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [April 22, 2011, 12:20am UTC](https://www.ruby-forum.com/t/question-about-memcache/206075/3 "2011-04-22T00:20:57Z")

</div>

Thank you for your help, António.

I have a question here, instead of memcache module, can I use other  
moudule, like proxy\_cache, fastcgi\_cache?

What is the advantage and disadvantage of using memcache?

Yanxin

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [April 22, 2011, 4:59am UTC](https://www.ruby-forum.com/t/question-about-memcache/206075/4 "2011-04-22T04:59:25Z")

</div>

On Fri, Apr 22, 2011 at 6:20 AM, Yanxin Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thank you for your help, Antnio.
> 
> I have a question here, instead of memcache module, can I use other  
> moudule, like proxy\_cache, fastcgi\_cache?
> 
> What is the advantage and disadvantage of using memcache?

The main advantage of using memcached is that you can have a  
distributed cache layer in a cluster setting by means of client-side  
key hashing. When you do have a lot of stuffs to cache or your disk is  
slow, it’ll be a big win. You may want to combine it with the  
ngx\_srcache module:

```
http://github.com/agentzh/srcache-nginx-module

```

The main disadvantage atm is that ngx\_srcache is rather weak in terms  
of functionality as compared to proxy\_cache and fastcgi\_cache. Also,  
memcached has a limit on item size (1MB), though most of the time,  
your pages are smaller than 1MB.

Cheers,  
-agentzh

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [April 23, 2011, 7:49am UTC](https://www.ruby-forum.com/t/question-about-memcache/206075/5 "2011-04-23T07:49:48Z")

</div>

Thank you so much, Yichun.  
I am going to use proxy\_cache for my application then.
