I am developing a custom theme for my Drupal 10 site. I found myself constantly flushing the cache, so I have been looking up ways to disable the cache on my local dev site. My end goal is to be able to simply refresh the page to see CSS changes. I need this in order to enable live reload at a later step.
I am having extreme difficulty disabling the cache, despite reading multiple Drupal docs and q/a's on stack overflow and stack exchange.
I tried many attempts outlined below over the past day and a half and each attempt failed. I also restarted Apache service after each attempt.
I found this Drupal doc and tried the steps:
- I disabled caching on the Admin interface. This included going to Admin -> Configuration -> Development -> Development Settings and toggling all of the options to on.
- When this didn't work, I went to Admin -> Configuration -> Performance and changed Caching to
I tried the solutions in the question mine was closed as a duplicate of. This question said this was due to Apache caching static files but didn't explain how to fix this. I found this second question that explained how to modify the
.htaccess file to disable caching. I added the below config to my
.htaccess file in my root directory:
<IfModule mod_rewrite.c> RewriteEngine on <FilesMatch "\.(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> </IfModule>
- Made sure that my
httpd.confis loading mod_rewrite
- Added EnableSendfile off to
I tried the other answer on the question used to close mine which recommended to remove
version: VERSION from the
info.yml file. I also read through the posted blog. I tried removing the line as it recommended but this did not work.
I read through the string of q/a's and blogs which suggested removing VERSION from the
libraries.yml file which also didn't work.
As per a comment on my first question, I added
$settings['deployment_identifier'] = 'A1234'; to my
I followed the steps here created a
settings.local.php file. I added the below:
$config['system.performance']['css']['preprocess'] = FALSE; $config['system.performance']['js']['preprocess'] = FALSE; $settings['cache']['bins']['render'] = 'cache.backend.null'; $settings['cache']['bins']['page'] = 'cache.backend.null'; $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
After all of these failed attempts, I don't understand what I am missing and I really want to learn how to fix this. I am open to any possible solutions or things I haven't tried.
I previously posted this question but it was closed as a duplicate and linked to a solution that doesn't even fix my issue which is pretty frustrating. Seeing that it wasn't reviewed and reopened, I decided to submit a new question with much more detail so that hopefully this one isn't simply closed.
- This is in a local development environment on my computer not an external host
- I am not using the color module which is known to cause similar issues
- Stack Exchange suggested this similar answer, but it also didn't help