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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:53:29+00:00 2026-05-23T16:53:29+00:00

We have sensitive files on a server. We want these to be accessible only

  • 0

We have sensitive files on a server. We want these to be accessible only to logged in users, so we serve them through a PHP script which checks whether the user has permission to view these files. Then we serve the file with readfile().

This works fine, but it’s my understanding that readfile() will load the entire file into memory, and then serve it, while virtual() will serve it directly from PHP, and thus reduce the stress on the server’s memory. readfile() is working fine for now, but a new client wants the same functionality with much larger files, and I was wondering whether moving to virtual() would be better.

  1. Is my understanding of readfile() and virtual() correct?
  2. Are there any gotchas with, for example, caching? Or anything else I haven’t thought of?
  • 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-23T16:53:30+00:00Added an answer on May 23, 2026 at 4:53 pm

    Yes, you are correct. virtual() will make PHP use less memory, but Apache will issue one extra request.

    A better way would be the Apache X-Sendfile module. All you’d need to do from PHP is an extra header() call and Apache will serve the file for you, instead of PHP. That uses even less resources.

    Here’s a tutorial

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

Sidebar

Related Questions

I have some sensitive files that I want the web server to be able
I have sensitive files to download to users, and each user is permitted to
I have a .ini file with sensitive information in my php wab app. I
I have a case sensitive SERVER (SQL_Latin1_General_CP1_CS_AS) but the Database is Case insensitive (SQL_Latin1_General_CP1_CI_AS).
I have a Lucene index which is currently case sensitive. I want to add
I've been trying my hand at OO PHP, and currently have three files. I
I want to setup a CRON that runs a PHP script that in turn
I will have clients upload pdf files with sensitive information. I'm planning on having
I have to encrypt/decrypt some sensitive information in a Xml file? Yes I can
I have a winforms application that presently ships with a chm file for context-sensitive

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.