# Memc\_flags\_to\_last\_modified and srcache , no 304 possible?

**URL:** <https://www.ruby-forum.com/t/memc-flags-to-last-modified-and-srcache-no-304-possible/218510>\
**Category:** NGINX\
**Created:** [April 2, 2012, 11:22pm UTC](https://www.ruby-forum.com/t/memc-flags-to-last-modified-and-srcache-no-304-possible/218510 "2012-04-02T23:22:05Z")\
**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 2, 2012, 11:22pm UTC](https://www.ruby-forum.com/t/memc-flags-to-last-modified-and-srcache-no-304-possible/218510/1 "2012-04-02T23:22:05Z")

</div>

Hello All,

Is it possible to use the memc\_flags\_to\_last\_modified directive with  
srcache ?  
It doesn’t work for me.

When a browser request nginx with a “If-Modified-Since” header, I would  
like that nginx lookup in memcached to verify if the “Last Modified” is  
the same and honor the 304 request without hit the proxied server (in  
another country).

Impossible to get a 304, so no bandwith saved … But my provider is  
happy 🙂

Thanks for your help !  
I working on for several days, i’ll really go mad 🙂

My config:

#user nobody;  
worker\_processes 1;

events {  
worker\_connections 1024;  
}

http {  
include mime.types;  
default\_type application/octet-stream;  
sendfile on;  
keepalive\_timeout 0;  
server\_tokens off;

```
upstream memc1 {
    server XX.XX.XX.XX:11211;
    server unix:/tmp/memcached.sock backup;
    keepalive 1024;
}
upstream memc2 {
    server XX.XX.XX.XX:11211;
    keepalive 1024;
}
upstream_list MemCluster memc1 memc2;

```

access\_log /var/log/nginx/access.log;

```
server {
    listen 80;
    server_name localhost;

 location = /memc {
        internal;

    set $memc_key $query_string;
    set $memc_exptime 0;
    set_hashed_upstream $backend MemCluster $memc_key;
    memc_pass $backend;
    memc_flags_to_last_modified on;
    }

    location / {
        set $key $uri;
        srcache_fetch GET /memc $key;
        srcache_store PUT /memc $key;

        proxy_pass http://the-far-far-away-server;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root html;
    }
}

```

}

Regards

Posted at Nginx Forum:

> **[memc\_flags\_to\_last\_modified and srcache , no 304 possible ?](https://forum.nginx.org/read.php?2,224793,224793#msg-224793)**
>
> Hello All, Is it possible to use the memc\_flags\_to\_last\_modified directive with srcache ? It doesn't work for me. When a browser request nginx with a "If-Modified-Since" header, I would like that nginx lookup in memcached to verify if the...

---

<div class="post-metadata">

**Author:** ![Nginx\_User777](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@Nginx\_User777](https://www.ruby-forum.com/u/Nginx_User777)\
**Post date:** [April 4, 2012, 5:24am UTC](https://www.ruby-forum.com/t/memc-flags-to-last-modified-and-srcache-no-304-possible/218510/2 "2012-04-04T05:24:03Z")

</div>

On Tue, Apr 3, 2012 at 5:21 AM, Nginx\_User777 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> happy 🙂
> 
> Thanks for your help !  
> I working on for several days, i’ll really go mad 🙂

This is a TODO item for ngx\_srcache. I’ll look into this in the near  
future. Thanks for reminding me of this 🙂

Best regards,  
-agentzh

---

<div class="post-metadata">

**Author:** ![Nginx\_User777](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@Nginx\_User777](https://www.ruby-forum.com/u/Nginx_User777)\
**Post date:** [May 11, 2012, 8:50am UTC](https://www.ruby-forum.com/t/memc-flags-to-last-modified-and-srcache-no-304-possible/218510/3 "2012-05-11T08:50:00Z")

</div>

On Wed, Apr 4, 2012 at 11:23 AM, agentzh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Impossible to get a 304, so no bandwith saved … But my provider is  
> > happy 🙂
> > 
> > Thanks for your help !  
> > I working on for several days, i’ll really go mad 🙂
> 
> This is a TODO item for ngx\_srcache. I’ll look into this in the near  
> future. Thanks for reminding me of this 🙂

I’ve just committed a patch to ngx\_srcache’s git master to add support  
for conditional GET requests (for both If-Modified-Since and  
If-Unmodified-Since):

```
https://github.com/agentzh/srcache-nginx-module/commit/1df1c56

```

I’ve also included some tests for this feature 🙂

Enjoy!  
-agentzh

---

<div class="post-metadata">

**Author:** ![Nginx\_User777](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@Nginx\_User777](https://www.ruby-forum.com/u/Nginx_User777)\
**Post date:** [April 4, 2012, 11:34am UTC](https://www.ruby-forum.com/t/memc-flags-to-last-modified-and-srcache-no-304-possible/218510/4 "2012-04-04T11:34:04Z")

</div>

Hi Agentzh,

Thanks for your answer.

I’ll continue to work with a srcache\_fetch\_skip to honor 304.

And a really big thanks for these excellent modules, it’s great !!!

Best Regards.

Posted at Nginx Forum:

> **[Re: memc\_flags\_to\_last\_modified and srcache , no 304 possible ?](https://forum.nginx.org/read.php?2,224793,224923#msg-224923)**
>
> Hello All, Is it possible to use the memc\_flags\_to\_last\_modified directive with srcache ? It doesn't work for me. When a browser request nginx with a "If-Modified-Since" header, I would like that nginx lookup in memcached to verify if the...

---

<div class="post-metadata">

**Author:** ![Nginx\_User777](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@Nginx\_User777](https://www.ruby-forum.com/u/Nginx_User777)\
**Post date:** [May 14, 2012, 2:07pm UTC](https://www.ruby-forum.com/t/memc-flags-to-last-modified-and-srcache-no-304-possible/218510/5 "2012-05-14T14:07:52Z")

</div>

You 're great !

I’ll test it quickly 😉

Thanks for this and all others stuffs

Posted at Nginx Forum:

> **[Re: memc\_flags\_to\_last\_modified and srcache , no 304 possible ?](https://forum.nginx.org/read.php?2,224793,226390#msg-226390)**
>
> Hello All, Is it possible to use the memc\_flags\_to\_last\_modified directive with srcache ? It doesn't work for me. When a browser request nginx with a "If-Modified-Since" header, I would like that nginx lookup in memcached to verify if the...
