Hallo,
ich habe ein Problem mit dem IIS-Express (Version 10.0) und gzip. Es handelt sich um eine Asp.Net 5-Anwendung, falls das eine Rolle spielen sollte.
Leider werden keine .js-Dateien vom IIS-Express mit gzip komprimiert. Für statische .html-Dateien funktioniert das einwandfrei.
Ebenfalls funktioniert gzip für .js-Dateien im normalen IIS (nicht Express) in der Version 8.5.
Ich habe schon viele Änderungen der Config versucht. Hier ist der Abschnitt zur Compression:
<httpCompression directory="%TEMP%\iisexpress\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%IIS_BIN%\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
Hat jemand eine Idee an was es liegen könnte, dass .js-Dateien nicht gzip't werden oder kann das "Problem" reproduzieren?
JavaScript ist text/javascript
(auch wenn es als depricated markiert ist).
Dazu muss die statische Kompressionskomponente im IIS installiert sein.
- performance is a feature -
Microsoft MVP - @Website - @AzureStuttgart - github.com/BenjaminAbt - Sustainable Code
Hallo Abt,
die statische Kompressionskomponente ist installiert. Im normalen IIS funktioniert ja auch alles wunderbar, nur nicht im IIS-Express.
Ich habe in der Config auch bereits text/javascript
versucht, jedoch ohne Erfolg.
Ach Express - überlesen. Da musste die Config via CMD setzen.
Auswendig weiß ichs nicht aber dafür gibts ja Google 😉
GZip response on IIS Express
- performance is a feature -
Microsoft MVP - @Website - @AzureStuttgart - github.com/BenjaminAbt - Sustainable Code
Den Stackoverflow-Beitrag habe ich auch schon gefunden und habe es auch damit schon versucht.
Leider hat das auch nicht geholfen.
Edit:
Es scheint wohl doch an einer Besonderheit von Asp.net 5 zu liegen. Ich habe nochmal zwei neue Web-Projekte angelegt, jeweils für das "alte" Asp.net und Asp.net 5.
Bei vorigem funktioniert gzip für .js problemlos. In Asp.net 5 leider nicht.
Edit 2:
Problem gelöst. In Asp.net 5 werden bei Verwendung von static files die Dateierweiterungen separat verwaltet: https://github.com/aspnet/StaticFiles/blob/dev/src/Microsoft.AspNet.StaticFiles/FileExtensionContentTypeProvider.cs
Die Lösung ist, in der Startup-Klasse anstelle von app.UseStaticFiles()
folgendes zu verwenden:
var option = new StaticFileOptions();
var contentTypeProvider = (FileExtensionContentTypeProvider)option.ContentTypeProvider;
contentTypeProvider.Mappings.Remove(".js");
contentTypeProvider.Mappings.Add(".js", "text/javascript");
app.UseStaticFiles(option);