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 7413681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:56:38+00:00 2026-05-29T06:56:38+00:00

I have CMS with a script that is executed for each file that is

  • 0

I have CMS with a script that is executed for each file that is accessed in the folder /files.

I’ve set this up with a RewriteRule in /files/.htaccess

RewriteRule ^(.*) ../file_tracker?path=/$1

There two things the file_tracker.php script should do:

  • Tracking: keep a log of how many times a file was accessed and when it was last accessed.
  • Authorization: for instance files in /files/secure require a login-session.

When you have a script like this, you need to do much more, such as:

  • Return a 404 status code if the file doesn’t exist – requires a file_exists check
  • Output the correct MIME-type headers – this is a nightmare in PHP if you allow any filetype to be served
  • Output sensible caching headers – custom E-tags?

I want this script to be as fast as possible because some pages have a lot of files, a 100ms overhead is already too much. Right now I’m thinking of a simple log to do the tracking, with a scheduled task that will do the bulk updates. Authorization will be more resource intensive but I guess I can’t avoid that. The last part I would like to have Apache do, since it seems to be very good at it: correct headers, E-tags for caching, and all that fanciness.

I’m pretty sure I can’t be the only one with this issue. Any suggestions?


Upd: I have no code to show because there is no relevant code. The things I could implement are so trivial it’s not even worth posting. This is an advance topic. ‘use header()‘ is not the kind of suggestions I’m looking for.


X-Sendfile would be the perfect solution, but it’s not enabled by default on most hosts, so I can’t rely on it.

  • 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-05-29T06:56:38+00:00Added an answer on May 29, 2026 at 6:56 am

    I suppose this just boils down to access logging in PHP. The authorization is a different issue all together. I’ll close this question and make a new one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a bit of a specific request unfortunately. I have a CMS that
Please refer to this page for reference: http://loadedgranola.valitics.com/_product_83484/blackberry_lime I have a jQuery script that
I have a CMS that uses a syntax based on HTML comments to let
We have a CMS which has several thousand text/html files in it. It turns
At my current job we have a CMS system that is .NET/SQL Server based.
For our CMS we have a site manager that defines the site's tree structure
(1) I have a site that serves up MP3 files: http://domain/files/1234567890.mp3 (2) I have
Amazon Integration I have my own CMS which has a file manager. A lot
If I have a cms, shopping cart, or some db based web script and
I have an image map that uses a third party script(mapper.netzgesta.de) to highlight the

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.