Eingebundene CSS- und JS-Dateien können nicht komprimiert werden

Eingebundene CSS- und JS-Dateien können nicht komprimiert werden

Ich habe die Komprimierung über .htaccess und in httpd.conf aktiviert

Wenn ich es jedoch durch die verschiedenen Online-Tester laufen lasse, wird immer angezeigt, dass verschiedene enthaltene Dateien nicht komprimiert sind. Die Apache-Version ist 2.2.15

.htaccess sieht derzeit folgendermaßen aus:

    ## EXPIRES CACHING ##

ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType application/javascript "access 2 days"
ExpiresByType application/x-javascript "access 2 days"
ExpiresByType text/javascript "access 1 month"
ExpiresByType text/x-javascript "access 2 days"
ExpiresDefault "access 2 days"


## TYPES FIX
AddType text/css .css
AddType text/javascript .js

## COMPRESS FILES ## 
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
Header append Vary User-Agent env=!dont-vary 


#Remove ETags
FileETag none


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond /home/sites/mydomain.info/public_html/wp-content/sitemaps%{REQUEST_URI} -f
RewriteRule \.xml(\.gz)?$ /wp-content/sitemaps%{REQUEST_URI} [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

httpd.conf enthält Folgendes:

#
# Deflate output configuration
# 
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

Ich kann online nichts finden, das darauf hinweist, dass dies mit den eingeschlossenen Dateien nicht funktionieren würde. Offensichtlich mache ich irgendwo einen Fehler, daher wäre ich für jede Hilfe sehr dankbar.

Antwort1

Sie können versuchen, die Cache-Steuerung hinzuzufügen:

# CACHE-CONTROL HEADERS
<FilesMatch "\\.(ico|jpe?g|png|gif|swf|gz|ttf)$">
Header set Cache-Control "max-age=2797200, public"
</FilesMatch>
<FilesMatch "\\.(css)$">
Header set Cache-Control "max-age=2797200, public"
</FilesMatch>
<FilesMatch "\\.(js)$">
Header set Cache-Control "max-age=2797200, private"
</FilesMatch>
<filesMatch "\\.(html|htm)$">
Header set Cache-Control "max-age=86400, public"
</filesMatch>
# Disable caching for scripts and other dynamic files
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Sat, 2 Aug 1980 15:15:00 GMT"
</FilesMatch>

und stellen Sie die Komprimierungsstufe ein

# MOD_DEFLATE COMPRESSION
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript application/x-httpd-php
DeflateCompressionLevel 9

verwandte Informationen