Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8513365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:32:45+00:00 2026-06-11T04:32:45+00:00

I have a nodejs server and SSL enabled nginx on 2 separate machines. Request/response

  • 0

I have a nodejs server and SSL enabled nginx on 2 separate machines. Request/response all work properly, however I have some problems getting nginx to cache stuff. My server configuration is below. Initially, I had the proxy cache statement in the ‘location /’ block, and at the time it was caching only my index page. I read that nginx won’t cache requests with set-cookie headers, so I ignored them as well (although it didn’t stop my index page from getting cached earlier). I tried fiddling with this for a whole day, but couldn’t get nginx to cache my js and css files. All such requests are getting routed back to my node server. Access logs and error logs don’t have any unusual entries. What am I doing wrong?

server {
    listen 443 ssl;
    server_name example.com;

    ssl_certificate /webserver/nginx/credentials/cert;
    ssl_certificate_key /webserver/nginx/credentials/key;
    ssl_session_cache shared:SSL:10m;

    location ~ .*\.(ico|css|js|gif|jpe?g|png)$ {
        proxy_pass http://somewhere:80;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_redirect http:// https://;

        proxy_ignore_headers "Set-Cookie";
        proxy_cache one;
        proxy_cache_valid 200 1d;
        proxy_cache_valid any 1m;
        expires 7d;
        proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
    }

    location / {
        proxy_pass http://somewhere:80;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_redirect http:// https://;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:32:46+00:00Added an answer on June 11, 2026 at 4:32 am

    This is what I’m using (I don’t have SSL enabled but I don’t think that is the problem). You’re missing the try_files line that tells nginx to look for the files in the root before passing off to the proxy. Also, it’s not really a caching problem – none of the static file requests should ever be hitting your node.js backend with this configuration.

    server {
      root        /public;
      listen      80;
      server_name _;
      index       index.html index.htm;
          charset     utf-8;
    
      # proxy request to node
      location @proxy {
        proxy_set_header   Host             $http_host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-NginX-Proxy    true;
    
        proxy_pass         http://127.0.0.1:3010;
        proxy_redirect     off;
        break;
      }  
    
      location / {
        try_files $uri.html $uri $uri/ @proxy;
      }
    
      #  static content
      location ~ \.(?:ico|jpg|css|png|js|swf|woff|eot|svg|ttf|html|gif)$ {
        access_log  off;
        log_not_found off;
        add_header  Pragma "public";
        add_header  Cache-Control "public";
        expires     30d;  
      }
    
      location ~ /\. {
        access_log    off;
        log_not_found off;
        deny all;
      }
    
      error_page 500 502 503 504 /50x.html;
          location = /50x.html {
          }
    
          error_page 404 /404.html;
          location = /404.html {
          }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have installed nodejs and mysql(also the work bench) I am building a server
I have an ssl/tls server (nodejs) that acts as a proxy to postfix/sendmail to
I have a nodeJS server running. There are some requests that the server will
Let's say I have a nodejs/express application on production server. If I want to
I have a nodejs TCP server and a client. Basic network communication happens. Client
I made the simple hello world NODEJS Server. I have a enyo web service
I have a mp3 file on my server. And i want all my clients
I have a NodeJS server running which is sucessfully acessed by 2 domains though
I have a NodeJs server connecting to redis. I also have a program using
I have been trying to connect sphinx server with nodejs and limestone module. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.