Add .js to combined assets

Hello,

It would be great to add .js extension to combined JS files.

Cause actually, the file looks like this :

https://www.mywebsite.com/combine/c10e5ef0d0d4b292f77b24564c7ae88e-1670839598

With some hosts, it can bring some problems. With plesk for example, I get this error :

Refused to execute script from 'https://www.mywebsite.com/combine/055643b60f539d6fb30ace263faf2198-1670839598' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

It can probably be fixed on the server side (didn’t find solution yet so I disabled minification), but it would be even better in my opinion to keep the file extension. Even minified and combined, it’s still .js after all.

What do you think about it ? Is there a good reason to not keep the file extension on combined files ?

Best regards,

Alex

It can probably be fixed on the server side (didn’t find solution yet so I disabled minification), but it would be even better in my opinion to keep the file extension. Even minified and combined, it’s still .js after all.

Just put .js or .css after combined tag in Twig, it will fetch the same resource as without it.

1 Like

Example:

<link href="{{ ['assets/less/theme.less']|theme }}.css" rel="stylesheet">

Smart, I didn’t think about it.

Hi,

I was looking for this as the original combiner asset url did not include a suffix like .css or .js and Lighthouse is complaining about those resources not having an efficient caching policy.

The above strategy works as long as the following snippet (with the caching policy) is not present in my additional nginx configuration:

location ~* \.(js|jpg|jpeg|gif|png|css|tgz|gz|rar|bz2|doc|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|woff|woff2|svg|webp)$ {
	etag on;
	if_modified_since exact;
	add_header Pragma "public";
	add_header Cache-Control "max-age=31536000, public";
}

But if I remove this, Lighthouse is complaining that I did not provide an efficient caching policy or all the other resources like jpgs, pngs, woff2, svg…

I included this snippet above what is recommended under the tab Server specific configuration - nginx:
https://docs.octobercms.com/3.x/setup/web-server-config.html#safe-mode

Does anyone know how I can create an efficient caching policy in nginx while still making use of the extensions in the combiner asset url?

Thanks in advance.