I have a Drupal project on heroku and it works fine, until a dyno restart. After that, the Css and Js on the Drupal site stop working. Whenever that happens, I have to do a flush cache to get the site working. From my understanding, flushing cache creates files that Drupal uses for Css and Js. Since the storage system on Heroku is ephemeral, after dyno every restart I lose that file. Thus, I am forced to do a cache flush to get that file again and make everything on the site work. Is there a way around this? Is there a way to change the folder location of the temporary file that is created?
-
Adding to that, the issue is generated because Drupal tries to use css files from /sites/default/files/css/css_randomhash. After every cache flush this changes. Is there any way to stop Drupal from trying to use these files, and generating them on every run. I tried "$config['system.performance']['css']['preprocess'] = FALSE; $config['system.performance']['js']['preprocess'] = FALSE;" but that didn't help– Aves2432Commented Dec 2, 2020 at 21:02
-
I wouldn't disable aggregation. Sounds like a Heroku workflow problem maybe?– KevinCommented Dec 2, 2020 at 22:21
-
Thank you, I know it's a bad idea but it was a one off project, so performance wasn't an issue. I eventually got it working by going to performance, and disabling the caching for js and css from there.– Aves2432Commented Dec 3, 2020 at 15:21
1 Answer
I eventually got the site working by disabling caching. But better approach to this problem is, creating the site on your local instance first. You need to create and install Drupal on your local system. If you install it directly on Heroku, it creates some temporary file on Heroku, which Heroku discards after every dyno restart. Even settings.php loses all the changes made to it(during installation) after dyno restart. (I installed my site directly on Heroku, so I got through this issue by adding changes to settings.php manually)
Once you create the Drupal site on your local instance (using the GUI), you will have some files in sites/default/files, as well as some changes in settings.php (hash salt, database setting etc). Now, you can track all these files and push it to Heroku. The site should work fine, except you won't be able to store any public files, you will need S3 bucket for that. Hope this helps who encountered similar issue!
-
What's the solution if we want a different version of settings.php between the local instance and the Heroku instance ? Commented Oct 27, 2023 at 12:36