skip to Main Content

I CANNOT DISABLE caching of the PHP files, (haven’t tried html or JS files yet). I just migrated a really old server to the above specs, (except it has RHEL7.6).

I have been using vagrant as a dev server environment for 6 years. I just built a replica for development for the newly migrated server with CentOS 7.6, Apache, and PHP 5.6.40.

I cannot seem to edit and then test those changes at all. I have tried DOZENS of suggestions found online, and at the moment the only way to see any changes I make, is to destroy the box and vagrant up a new box. NOT A SOLUTION.

I’ve tried.
Inline PHP header statements inside the actual file

<?php header('Expires: '.gmdate('D, d M Y H:i:s GMT', time() + 3600)); ?>

-> FAIL

Adding .htaccess file to the directory I’m working in

 #Initialize mod_rewrite
RewriteEngine On
<FilesMatch ".(php|html|htm|js|css)$">
  FileETag None
  <IfModule mod_headers.c>
    Header unset ETag
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires "Wed, 12 Jan 1980 05:00:00 GMT"
  </IfModule>
</FilesMatch>

-> FAIL

Add to httpd.conf

<IfModule mod_headers.c>
    <filesmatch ".(html)$">
        Header set Cache-Control "no-cache"
    </filesmatch>
</IfModule>

-> FAIL

I created a php file with this to include for developing a file… cacheOff.php:

header("Content-Type: application/json");
header("Expires: 0");
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");

Then tried this in the file
-> FAIL

I tried commenting out any cache.conf files in the httpd folder conf.modules.d
00-base.conf

LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule cache_module modules/mod_cache.so
#LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule data_module modules/mod_data.so

-> FAIL

I found php.ini suggestions like opcache, but it isn’t in this version.

Here is my httpd.conf and php.ini files
VagrantServerFiles

HELP…. PLEASE
This should be easy, shouldn’t it????

2

Answers


  1. change, or add this line to php.ini:

     opcache.enable=0
    

    opcache is a php.ini.all type so it can be invoked in the php page like:

      ini_set (opcache.enable,0);
    

    by default, the value is 1 or “on” if not declared in php.ini

    Login or Signup to reply.
  2. Not certain, but if you’ve ruled out client side cache (which you have) and you don’t think you’re running a PHP-caching system (opcache/accelerator/etc) there are some Vagrant settings you might play around with:

    Either dropping the cache (manually I think this would look like: echo 1 > /proc/sys/vm/drop_caches)

    Or, possibly disabling sendfile() (see more on this answer: Vagrant/VirtualBox/Apache2 Strange Cache Behaviour)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search