Skip to content

$srcache_expire is always empty #61

@onnimonni

Description

@onnimonni

Hey!

I have been trying srcache with redis for few weeks now and today I noticed that the cache keys are not expiring automatically.

I'm using this config in local docker environment:

##
# Adds internal locations for storing and getting full page cache from redis
##

srcache_default_expire 10s;
srcache_max_expire 10s;

location /redis-fetch {
    internal;

    ##
    # In order to use password authentication we use custom redis module which adds $redis_auth:
    # - https://github.com/Yongke/ngx_http_redis-0.3.7
    ##

    # Read the configuration from system envs
    set $redis_auth '';
    set $redis_db 0;

    set $redis_key $args;

    redis_pass 172.17.0.6:6379;
}

location /redis-store {
    internal;

    set_unescape_uri $exptime $arg_exptime;
    set_unescape_uri $key $arg_key;

    # redis module pipelines these 3 commands into single request
    redis2_query auth '';
    redis2_query select 0;
    redis2_query set $key $echo_request_body;
    redis2_query expire $key $srcache_expire;

    # Pass the request to redis
    redis2_pass 172.17.0.6:6379;

}

Then I open redis-cli to monitor incoming requests:

$ redis-cli
> monitor
1478704802.63890 [0 172.17.0.8:54906] "select" "0"
1478704802.638100 [0 172.17.0.8:54906] "get" "wp_:nginx:httpsGETwordpress.test/robots.txt"
1478704802.638122 [0 172.17.0.8:54900] "auth" ""
1478704802.638137 [0 172.17.0.8:54900] "select" "0"
1478704802.638148 [0 172.17.0.8:54900] "set" "wp_:nginx:httpsGETwordpress.test/robots.txt" "HTTP/1.1 200 OK\r\nContent-Type: text/plain; charset=utf-8\r\nExpires: Thu, 19 Nov 1981 08:52:00 GMT\r\nCache-Control: no-store, no-cache, must-revalidate\r\nPragma: no-cache\r\nX-Robots-Tag: noindex, follow\r\nLink: <https://wordpress.test/wp-json/>; rel=\"https://api.w.org/\"\r\nLink: <https://wordpress.test/wp-json>; rel=\"https://github.com/WP-API/WP-API\"\r\nX-Cache: MISS\r\n\r\nUser-agent: *\nDisallow: /wp-admin/\nAllow: /wp-admin/admin-ajax.php\n"
1478704802.638189 [0 172.17.0.8:54900] "expire" "wp_:nginx:httpsGETwordpress.test/robots.txt" ""

And where I should see 10s because of the srcache_max_expire directive or 0 because of the Cache-Control: no-store, no-cache, must-revalidate header instead I see "" as sent to redis.

Version:

nginx -V
nginx version: openresty/1.11.2.1
built by gcc 4.9.2 (Debian 4.9.2-10)
built with OpenSSL 1.0.2j  26 Sep 2016
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.60 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.31 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.06 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.6 --add-module=../ngx_lua_upstream-0.06 --add-module=../headers-more-nginx-module-0.31 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.17 --add-module=../redis2-nginx-module-0.13 --add-module=../rds-json-nginx-module-0.14 --add-module=../rds-csv-nginx-module-0.07 --with-ld-opt=-Wl,-rpath,/etc/nginx/luajit/lib --with-http_addition_module --with-http_auth_request_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_geoip_module=dynamic --with-file-aio --with-ipv6 --with-pcre-jit --with-stream --with-stream_ssl_module --with-threads --without-http_autoindex_module --without-http_browser_module --without-http_userid_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_split_clients_module --without-http_uwsgi_module --without-http_scgi_module --without-http_referer_module --user=nginx --group=nginx --sbin-path=/usr/sbin --modules-path=/usr/lib/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx/nginx.lock --http-fastcgi-temp-path=/tmp/nginx/fastcgi --http-proxy-temp-path=/tmp/nginx/proxy --http-client-body-temp-path=/tmp/nginx/client_body --add-module=/tmp/ngx_http_redis-0.3.7-master --add-module=/tmp/ngx_pagespeed-1.11.33.4-beta --with-openssl=/tmp/openssl-1.0.2j

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions