Search code examples
apacheubuntulamp

How many times a file was requested from a server?


Is it somehow possible to see how many times a specific file was requested from the server, or set up a system to see it in the future?

In my case, it is a Javascript file on my server that is included on many different websites.

My setup is using LAMP.


Solution

  • So that JSON file is requested by HTTP requests going to your Apache server.

    That server probably manages log files. (the location of that log file is configurable).

    You then need to scan the access log file to find every access. You can use something like

    grep yourfile.json /var/log/www/access.log | wc
    

    (to count occurrences) where /var/log/www/access.log is your access log file.

    BTW, many log files are managed by logrotate. Details are system specific. Take than into account too.