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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:30:27+00:00 2026-06-06T06:30:27+00:00

I am including the same files multiple times on the same page. I noticed

  • 0

I am including the same files multiple times on the same page. I noticed when I do this, it seems PHP is caching the files. When I generate a random number with the rand function, it is the same in both includes. Anyone know how I can stop PHP from doing this? I tried some different header functions like this but they don’t work:

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0

Edit: Ok, I’m dumb and I forgot that I was calling the includes from a jquery script which I believe is caching the files. I went back to see the code some one was asking for and noticed it. Thanks everyone.

  • 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-06T06:30:29+00:00Added an answer on June 6, 2026 at 6:30 am

    I would suggest that including the same file multiple times is not particularly good practice.

    A better solution would be to include it once, and call the functions it contains multiple times.

    Obviously, this will mean changing the way the code works — I guess it’s currently written as a block of code that is run as soon as it it included. You’d need to change it so that it’s enclosed in a function (or several functions, as required) so that it can be called at will.

    Then just include it once at the start of your program.

    I know this doesn’t directly answer the question, but doing it this way is better coding practice, and will make your code much easier to manage and maintain.

    Hope that helps.

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

Sidebar

Related Questions

Does including the same header files multiple times increase the compilation time? For example,
I'm including the MySQLi connection file in the constructor of a PHP class. Since
There are a lot of tutorials that show on how to merge multiple files
I have a Product model which validates multiple attributes (including a Paperclip image attachment)
Suppose I have over 100 files called in via require_once() command. Is this inducing
How do you solve created by including a header file with the same name
I'm sandboxing my app, and trying to allow for import/export of multiple files, using
Including DISTINCT to an SQL query that also uses ORDER BY CAST(thecolumn AS int)
Im including the popular file jquery.form.js. I have the following: var options = {
While including the simple HTML DOM library, I get the warnings: Warning: file_get_contents() [function.file-get-contents]:

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.