Skip to content

Proxy Cache not working on heroku  #58

@sub2u

Description

@sub2u

I have a config which works on my local machine with proxy reverse cache. It bypass the hitting the box every time.

I used nginx-build pack with proxy cache but on nginx every time it hit the box i can observe heroku[router] on logs

providing the config for reference in bottom.

Sample config

daemon off; # Heroku dynos have at least 4 cores.

worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;

events {
use epoll;
accept_mutex on;
worker_connections 1024;
}

http {
gzip on;
gzip_comp_level 2;
gzip_min_length 512;

server_tokens off;

log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
access_log logs/nginx/access.log l2met;
error_log logs/nginx/error.log;

include mime.types;
default_type application/octet-stream;
sendfile on;

#Must read the body in 5 seconds.
client_body_timeout 5;

upstream app_server {
    server unix:/tmp/nginx.socket fail_timeout=0;
}

proxy_cache_path  /tmp/nginx  levels=1:2    keys_zone=STATIC:10m
                                 inactive=24h  max_size=1g;

server {
    listen <%= ENV["PORT"] %>;
    server_name _;
    keepalive_timeout 5;

    location  / {
        proxy_pass             http://app_server;
    }


    location  ~* ^/(.*)/(.*)/(.*).(jpe?g|png|[tg]iff?|svg) {
        proxy_pass             http://app_server;
        add_header Cache-Control public;
        add_header X-Cache-Status $upstream_cache_status
        proxy_set_header       Host $host;
        proxy_cache            STATIC;
        proxy_cache_valid      200  1d;
        proxy_cache_use_stale  error timeout invalid_header updating
                               http_500 http_502 http_503 http_504;
    }
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions