Background
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.
Problem
I am having extreme difficulty disabling the cache, despite reading multiple Drupal docs and q/a's on stack overflow and stack exchange.
Attempts
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.
Attempt 1
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
<no cache>
.
Attempt 2
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.conf
is loading mod_rewrite - Added EnableSendfile off to
httpd.conf
Attempt 3
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.
Attempt 4
As per a comment on my first question, I added $settings['deployment_identifier'] = 'A1234';
to my settings.php
file.
Attempt 5
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';
Conclusion
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.
Additional Info
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