0

I've created a simple HTML website with 4 html pages (4 links). The access.log doesn't update for accessing a html page more than once.


E.g. user clicks on link #1 -> link #2 -> link #1

The access.log will only show:

GET /page#1.html

GET /page#2.html

I want it show all requests, i.e.:

GET /page#1.html

GET /page#2.html

GET /page#1.html


I've looked into tailoring my .config file but to no success. Any help will be appreciated. Thank you.

Here is my nginx.config file:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 2048;
    multi_accept on;
}

http {

##
# Basic Settings
##

server_name_in_redirect off;
server_tokens off;
port_in_redirect off;

sendfile on;
tcp_nopush on;
tcp_nodelay off;
send_timeout 30;
keepalive_timeout 60;
keepalive_requests 200;
reset_timedout_connection on;
types_hash_max_size 2048;

server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
#default_type application/octet-stream;
default_type text/html;
charset UTF-8;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;

##
# Gzip Settings
##

gzip on;
gzip_min_length 256;
gzip_disable "msie6";

# gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Johno Cown
  • 29
  • 6
  • 1
    Because there was no request to the server. Your browser cached the file. Didn’t you check the console? – Mike Doe Mar 08 '20 at 17:16
  • @emix Hi thank you for the quick response, I am relatively new to networking. Why would there be no request to the server when the user is going back to page#1? – Johno Cown Mar 08 '20 at 17:20
  • I’ve already explained this: the file is in the browser’s cache. Press F12, the console is your friend. – Mike Doe Mar 08 '20 at 17:25
  • @emix I understand the requests are in the browser's cache and I can see them in the console. But multiple requests of a single page are not being cached to my access.log file. It seems like the web page is loaded to the user's system upon the 1st request and hence, it doesn't need send another request to the server upon the 2nd request of that web page. – Johno Cown Mar 08 '20 at 17:34
  • So what’s your question? You can tell nginx to tell browsers not to cache html files then. – Mike Doe Mar 08 '20 at 19:07
  • @emix Hi yes, I've added meta tags to my html pages to prevent browser caching. Thank you for your help :) – Johno Cown Mar 09 '20 at 19:38

2 Answers2

1

It's also possible that this is an access issue.

In my case, somehow the owner of the files was:

-rw-rw-r--   1 nginx root        0 Dec  2 10:53 error.log
-rw-rw-r--   1 nginx root        0 Dec  2 10:53 access.log

However the owner of the nginx directory was root:root

drwx------.  2 root   root               20480 Dec  2 17:02 nginx

What I had to do is delete all log files and restart nginx (Fedora Linux):

rm -rf nginx/*
systemctl reload nginx.service

After this the newly created files got correct permissions and were updated.

-rw-rw-r--   1 root root        0 Dec  2 17:02 error.log
-rw-rw-r--   1 root root        0 Dec  2 17:02 access.log
Aris
  • 4,643
  • 1
  • 41
  • 38
0

As @emix already pointed out, is the browser simply not making a request to your server. Instead the page is most likely going to be served from your browsers cache.

The (too) short answer to why browsers do this is, is to reduce unnecessary network requests and to save resources.

To get a better understanding of what a (browser) cache is, I'd recommend you to read the following resources:

Stackoverflow Q/A:

External sites:

Tom
  • 4,070
  • 4
  • 22
  • 50