How to use srcache_store while proxy_pass use to connect backend

n1xman nginx-forum at
Mon Mar 5 17:48:02 UTC 2012


I can't store data while I'm using proxy_pass to connect to the backend
if we can't find data on the memcached. srcache_fetch probes the
memcached but since no data, it connect to the backend and get the
correct data but not executing the srcache_store. Here is my config.

        location /memc {
                memc_connect_timeout 500ms; # 500 miliseconds
		memc_send_timeout 5000ms; # 5 seconds
		memc_read_timeout 500ms; # 500 miliseconds
		set $memc_key  $query_string;
                set $memc_exptime 3600;

location /webservice {
        set $key $http_host$request_uri;
        srcache_fetch GET /memc $key;
        add_header X-Cached-From srcache-memcached;

	# store the content!
        srcache_store_statuses 200 201 301 302 404 503 502;
        srcache_store PUT /memc $key;
	# if it is not found we go to the backend
        proxy_pass http://remoteserver;

I use nginx-1.0.10. and I should be able to use proxy_pass to get
backend data while store data on the cache..?

If I comment the proxy_pass, srcache_store triggered and stored the 502
status page as it can't connect to the backend.

Please help me on how to use srcache_store and use proxy_pass to store
data and connect to backend.

Thanks in advance.

Posted at Nginx Forum:,223438,223438#msg-223438

More information about the nginx mailing list