Score:0

'Aggregate and compress CSS files' and 'Aggregate JavaScript files' don't work

cn flag

Recently selecting Aggregate and compress CSS files or Aggregate JavaScript files in the Performance page stopped working on a Drupal 7 site: When they are selected, the CSS/JavaScript file won't load.

I have cloned the site on another server and the problem doesn't occur there. The PHP version and the Drupal version (7.89) is the same.

How can I debug what is going on here?

Edit: Additional info

As I mentioned in the comments, the aggregated CSS files are not viewable in the browser. However, If I change the filename to e.g. test.css, it then is viewable.

Further:

Each aggregate file has a corresponding .gz of the same name. When I delete this the .css file is then viewable via the browser. So it looks like the issue has something to with these .gz files.

No Sssweat avatar
ua flag
Typically this is due to a folder permission issue. Make sure the `/sites/default/files` folder has the correct folder owner and group besides having the appropriate `chmod 755` permissions.
cn flag
Unfortunately in this case the permissions are correct.
id flag
What does "When they are selected, the CSS/JavaScript file won't load" actually mean? Are the files not generated on disk, or not referenced properly in the HTML?
cn flag
@cilefen E.g There are references to aggregated CSS within the HTML. When I open these via FTP they have data within them, but I try and view them in the browser via the site's HTML they are apparently empty.
id flag
How does the web server's configuration differ between the working site's and broken site's?
id flag
Also: they are empty? Is the HTTP response a 200 code?
cn flag
@cilefen both Apache, both running PHP 7.4. The empty pages have a 200 response.
id flag
Are the web server's configurations identical?
cn flag
@cilefen probably not. The working one is a shared server, the non-working one is a VPS with the same company. I'm not sure how to find detailed info re: the configurations (aside from asking them of course).
cn flag
It seems like new aggregate CSS files are not created when there's a change and aggregation is then chosen.
Score:2
cn flag

Well it turns out that mod_headers wasn't enabled on my server, which therefore meant that the '# Rules to correctly serve gzip compressed CSS and JS files' section within .htaccess didn't work.

It used to be fine, so it looks like the hosting company changed the Apache config recently

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.