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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:28:39+00:00 2026-06-17T11:28:39+00:00

I have a local LAMP stack running on Linux. I have the usual Apache/PHP/mySQL

  • 0

I have a local LAMP stack running on Linux. I have the usual Apache/PHP/mySQL stuff, and everything works fine from localhost.

I have a small app on the server that displays a tree view. This lists a series of documents that are found locally (on the server). These files can be viewed by clicking them in the tree, at which point they are loaded into a DIV on the page. These files may be edited using a simple editor that I have written within the application. This works fine so far.

The problem is that PHP (I assume) is caching these documents as they are loaded, which means that when the user edits them, although they are saved, when they are reselected in the tree, the cached version is shown, and not the newly edited version.

The initial page of the app was a standard HTML page, but I have renamed it to PHP and added the following code to the top of this page:

<?php
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>

Unfortunately, while this seems to prevent the main page from being cached, it does not prevent those files that are loaded dynamical during the general use of the application.

Is there any way that I can prevent PHP (Still assuming that it is PHP) from caching these dynamically loaded, local files?

  • 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-17T11:28:40+00:00Added an answer on June 17, 2026 at 11:28 am

    You’re mixing up opcode cache and browser cache. The headers you are setting have nothing to do with PHP, they are http headers which influence the browser caching. PHP will (if it’s setup properly with APC or similar) cache the opcode, which has nothing to do with your problem.

    You have to set the caching headers on the file when you download them to the client for editing in order to prevent the client (browser) to cache them.

    Every download (css file, js file, whatever file) is a separate http request and therefore has its own headers set. So if you set custom per-request headers you’ll have to set them for each such request. In your case an easier solution would be to add those headers on the level of the Apache configuration.

    The Apache Header directive is easy to use and you can use it almost anywhere in the Apache configuration chain. That means .htacess, vhost config or general apache config. It’s up to you and your server environment, how you solve this.

    An example of how you could add a header to your .htaccess would be:

    Header set Cache-control "max-age=0, no-store"
    

    Or if you wish to set certain headers only for certain file types:

    <FilesMatch "\.(gif)$" >
        Header set Cache-control "max-age=0, no-store"
    </FilesMatch>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing in LAMP (Linux+Apache+MySQL+PHP) since I remember myself. But one question was bugging
I have local apache server, and I need to pass all requests from php
I have a PHP/MySQL application running with WAMP on a local server. This application
I have a local Database running on localhost:3306, which I access with MySQL Workbench.
I have a local build of my site running at local.mydomain.com. I'm making ajax
we have a local staging server running sql server 2000 and a remote public
I am currently doing local development on a webproject using a LAMP stack. Since
I have local table and string that must be populated from its values: DECLARE
Here's simplified .htaccess file: RewriteEngine On RewriteRule ^index$ index.php On my local lamp server
My work setup is a Windows XP host, running an Ubuntu VM LAMP stack.

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.