0

I have enabled aggregate CSS/JS from the backend. It stores the aggregated files in the local system. How do I make them accessible through the S3 bucket? I have already installed the S3fs module.

The point is when my server is down it automatically creates another instance. And that newly created instance does not have the previous aggregated CSS/JS files. Therefore, it breaks my website.

0

It's all explained in the module's README.txt

  • This will configure your site to store new uploaded files in S3. Files which your site creates automatically (such as aggregated CSS) will still be stored in the server's local filesystem, because Drupal is hard-coded to use the public:// filesystem for such files.

  • However, s3fs can be configured to handle these files as well. In settings.php you can enable the s3fs.use_s3_for_public and s3fs.use_s3_for_private settings to make s3fs take over the job of the public and/or private file systems. This will cause your site to store newly uploaded/generated files from the public/private file system in S3 instead of the local file system. However, it will make any existing files in those file systems become invisible to Drupal. To remedy this, you'll need to copy those files into your S3 bucket.

    Example: $settings['s3fs.use_s3_for_public'] = TRUE;

  • If you use s3fs for public, you should change your php twig storage folder to a local directory, php twig files in S3 produce latency and security issues (these files would be public). Please change the php_storage settings in your setting.php and choose a directory, out of docroot recommended.

    Example: $settings['php_storage']['twig']['directory'] = '../storage/php';

    If you have a multiple backends you may use a NAS to store it or other shared storage system with your others backends.


Related Question: Serve compressed JS and CSS with S3 as filesystem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.