Delay in code changes on custom pages in drupal 8 in a docker environment There is a delay between saving code changes in a controller and being able to view them in the browser.

This is frustrating (to say the least) and makes it very hard to develop and debug module code.

I have tried setting up a development environment in docker and it's working quite well except for this nasty and unpredictable delay.

For a minimal example I tried installing the Hello World example module from the Prepare a Module skeleton guide.

My (minimal, but complete) setup is available here: https://github.com/glaux/drupal8docker.

To replicate the delay


Get the site up and running.
Log in as admin with pass 123 on http://localhost:8090
Navigate to /hello
Change the markup in the file /docker/project/modules/D8HWexample/src/Controller/HelloController.php
Refresh /hello - the changes will show up after between 5 and 300 seconds.


What I've tried

I've tried disabling all the caches by following the official guides. When making css changes to a custom theme (not included in the minimal repo above) the code changes are visible immediately, so this is not a cache problem I believe.

This is also emphasized by the fact that rebuilding the cache via the interface, drush and/or drupal console seems to have no effect on this delay.

In a similar manner I've tried disabling the browser cache (by opening the dev console on chrome). This have no effect either, nor have clearing the browser cache manually.

How can I get rid of this delay, what am I doing wrong here?

Edit

I think Clive could be right that this is possibly on the file system level. Here is an excerpt from the docker-compose file:

volumes:
  - ./docker/project/modules:/var/www/html/modules
  - ./docker/project/themes:/var/www/html/themes
  - ./docker/project/libraries:/var/www/html/libraries
  - ./docker/project/profiles:/var/www/html/profiles
  - ./docker/project/sites:/var/www/html/sites
  # Add anonymous volumes to exclude cache files explicitly
  - /var/www/html/sites/default/files/js
  - /var/www/html/sites/default/files/css
  - /var/www/html/sites/default/files/php


The files are added as explicit volumes, and the changes I make to HelloController.php are reflected in the image. I'm running this on Windows 10. Could this be the culprit, and how can I test this?
Your image is based on drupal:8.4.3-apache, which sets an opcache revalidate frequency of 60 seconds:

# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
        echo 'opcache.memory_consumption=128'; \
        echo 'opcache.interned_strings_buffer=8'; \
        echo 'opcache.max_accelerated_files=4000'; \
        echo 'opcache.revalidate_freq=60'; \
        echo 'opcache.fast_shutdown=1'; \
        echo 'opcache.enable_cli=1'; \
    } &gt; /usr/local/etc/php/conf.d/opcache-recommended.ini


This means that if you access the same file within 60 seconds, it will be served from RAM instead.