Apache Vhost directives optimized for Pagespeed

I am currently using this setting in my vhost:

<Location />
  SetOutputFilter DEFLATE
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
  SetEnvIfNoCase Request_URI \
  \.(?:gif|jpe?g|png)$ no-gzip dont-vary
  Header append Vary User-Agent env=!dont-vary
</Location>
<Directory />
  ExpiresActive On
  ExpiresByType text/html "access plus 5 minutes"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/x-javascript "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType text/javascript "access plus 1 month"
  ExpiresByType image/gif "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType image/jpg "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/x-icon "access plus 1 month"
  ExpiresDefault "access plus 1 day"

  <FilesMatch "\.(ico|jpeg|pdf|flv|jpg|png|gif|js|css|swf)$">
    Header set Cache-Control "max-age=2592000, public"
    Header unset Last-Modified
    Header unset ETag
    FileETag None
  </FilesMatch>
  <FilesMatch "\.(html|php)$">
    Header set Cache-Control "max-age=900, public, must-revalidate"
  </FilesMatch>
</Directory>

While it works great to speed up this thing, sometimes users don’t see the changes they made on the content (mainly when using FireFox) :( any hints / tips for optimization?

+3
source share
3 answers

, , must-revalidate (, PHP), Expires Last-Modified. , , .

, .

+1

, javascript, css , , , - , .

, , JS script.js. , htaccess,

ExpiresByType application/x-javascript "access plus 1 month"  
ExpiresByType application/javascript "access plus 1 month"

javascript , , JS 1 , .

.

, script.js, HTML,

<script src="includes/script.100.js" type="text/javascript"></script>

<link rel="stylesheet" type="text/css" href="includes/style.100.css" />  

100 . , 1, 2, 3.. ( , ).

, htaccess, -

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^includes/style\.[\d]+\.css$ /includes/style.css [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^includes/script\.[\d]+\.js$ /includes/script.js [L]

, , , .

, , , , , .

0

Hannes , , js/css.

, , , . , , HTML - - .

, , URL- , hash, - md5 (time ( "U" ));

, URL-, ​​ , -

http://test.com/controller/functionname/

, URL-, ,

http://test.com/controller/functionname/?hash= {something}.

, . , , -.

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
0

Source: https://habr.com/ru/post/1777863/


All Articles