Can I even add expires headers to...

User 404575 Photo


Registered User
887 posts

From Gtmetrix for http://ColoradoProcessServers.net:

Add Expires headers
C (78)

17%
Server High
What does this mean?
There are 2 static components without a far-future expiration date.

http://www.google-analytics.com/ga.js
https://apis.google.com/js/plusone.js


But I added expires headers:

## EXPIRES CACHING ##
<IfModule mod_expires.c>
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 year"
ExpiresByType text/js "access 1 year"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 year"
</IfModule>
## EXPIRES CACHING ##

So it seems like they don't work, for files served by someone else?

Yet I'm now using Cloudflare, which seems cool ( getting .88 second page load time? )
and those files are being served from all over, right?

Confused...
Melissa Rhiannon
OS Windows 10
User 122279 Photo


Senior Advisor
14,648 posts
Online Now

I would think you have to use 'months' and 'years', even though they are singular. And those two java scripts should be covered if you change this line

'ExpiresByType text/js "access 1 years" ' so that you write 'javascript' instead of just 'js'.

Did you add this to your server's .htaccess file? That is what is recommended.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 122279 Photo


Senior Advisor
14,648 posts
Online Now

The meaning of this:

Add Expires headers
C (78)

17%
Server High


as far as I can understand, is that you're getting 78 out of 100 points for this criteria, it's processed at the server (hence my question about the .htaccess file), and it has high priority when it comes to improving the performance. The 17% is the average score that sites have, so you are way above that.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 404575 Photo


Registered User
887 posts

Yes, using .htaccess file. I took your suggestion, thank you Inger, and changed it.

The whole file is now below, but it apparently makes no difference in those files that are served from somewhere else.

SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ \
no-gzip dont-vary
SetEnvIfNoCase Request_URI \
\.(?:exe|t?gz|zip|bz2|sit|rar)$ \
no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html


## EXPIRES CACHING ##
<IfModule mod_expires.c>
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 year"
ExpiresByType text/javascript "access 1 year"
ExpiresByType application/pdf "access 1 year"
ExpiresByType text/x-javascript "access 1 year"
ExpiresByType application/x-shockwave-flash "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 year"
</IfModule>
## EXPIRES CACHING ##


# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
<IfModule mod_setenvif.c>
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
</IfModule>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
</IfModule>
</IfModule>
<FilesMatch "\.(css|js|htc|CSS|JS|HTC)$">
FileETag None
<IfModule mod_headers.c>
Header set X-Powered-By "W3 Total Cache/0.9.2.4"
</IfModule>
</FilesMatch>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
FileETag None
<IfModule mod_headers.c>
Header set X-Powered-By "W3 Total Cache/0.9.2.4"
</IfModule>
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
FileETag None
<IfModule mod_headers.c>
Header set X-Powered-By "W3 Total Cache/0.9.2.4"
</IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*\/)?w3tc_rewrite_test$ $1?w3tc_rewrite_test=1 [L]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{HTTP_HOST} =coloradoprocessservers.net
RewriteCond %{REQUEST_URI} \/$ [OR]
RewriteCond %{REQUEST_URI} (sitemap(_index)?\.xml(\.gz)?|[a-z0-9_\-]+-sitemap([0-9]+)?\.xml(\.gz)?) [NC]
RewriteCond %{REQUEST_URI} !(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|\/feed\/|wp-.*\.php|index\.php) [NC,OR]
RewriteCond %{REQUEST_URI} (wp-comments-popup\.php|wp-links-opml\.php|wp-locations\.php) [NC]
RewriteCond %{HTTP_COOKIE} !(comment_author|wp-postpass|wordpress_\[a-f0-9\]\+|wordpress_logged_in) [NC]
RewriteCond %{HTTP_USER_AGENT} !(W3\ Total\ Cache/0\.9\.2\.4) [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/w3tc/pgcache/%{REQUEST_URI}/_index%{ENV:W3TC_UA}%{ENV:W3TC_REF}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" -f
RewriteRule .* "/wp-content/w3tc/pgcache/%{REQUEST_URI}/_index%{ENV:W3TC_UA}%{ENV:W3TC_REF}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


Melissa Rhiannon
OS Windows 10
User 404575 Photo


Registered User
887 posts

Another time consuming one is:
get valid-xhtml10 slow loading

No idea what that does.

This operation from W3C is apparently eating up 166ms and get plusone.js is eating up 215ms.

Get sprite2.png ( having to do with the plusone button ) is eating an additional 93ms on the end.
Why won't Google get their act together, being they're also pushing faster page speeds?

Melissa Rhiannon
OS Windows 10
User 122279 Photo


Senior Advisor
14,648 posts
Online Now

Files served from somewhere else - does that mean files that you link to, and that are sitting on a different server where you have no access?

I don't think you can control the loading speed of those. That will have to be done by someone who can access the server that they come from.

Your .htaccess file seems to be very WP specific, so for a non WP user it's a bit hard to understand. Maybe a question in the WP forum will produce some more insight?

There is also another way of setting expires. It can be set as a meta tag in the document head like this:
<META HTTP-EQUIV="cache-control" CONTENT="Public">
<META HTTP-EQUIV="expires" CONTENT="Fri, 10 Feb 2013 11:53:57 GMT">

When setting a date, it MUST be in the above format and in GMT
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 404575 Photo


Registered User
887 posts

Inger Eik wrote:
Files served from somewhere else - does that mean files that you link to, and that are sitting on a different server where you have no access?

I don't think you can control the loading speed of those. That will have to be done by someone who can access the server that they come from.

Your .htaccess file seems to be very WP specific, so for a non WP user it's a bit hard to understand. Maybe a question in the WP forum will produce some more insight?

There is also another way of setting expires. It can be set as a meta tag in the document head like this:
<META HTTP-EQUIV="cache-control" CONTENT="Public">
<META HTTP-EQUIV="expires" CONTENT="Fri, 10 Feb 2013 11:53:57 GMT">

When setting a date, it MUST be in the above format and in GMT


No, not the loading speed, the expirations. Some of the speed problems being identified, are based on some of the js and graphics being hosted elsewhere, therefore I'm not sure if my expires headers can apply to them that way.

Melissa Rhiannon
OS Windows 10
User 122279 Photo


Senior Advisor
14,648 posts
Online Now

I have googled a bit, and all references to expires headers are about 10-12 years old, and always mentioning HTML1.0 in the examples. I guess they (the expires headers) were more important then, with dialup connections being fairly common.

And it does have something to do with loading speed, not on the first visit, but by revisits, as all the page elements will be cached if the expies date is set to some date in the far future. Problems would arise, of course, if an image or two or something in the css file, were changed out in the meantime. The old images/css would then be loaded from the browser cache.

Actually, the only new reference to expires headers I found is here:
http://www.webmarketingnow.com/tips/met … ml#expires
This is from 2011 and advises against using them.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 404575 Photo


Registered User
887 posts

Inger Eik wrote:
I have googled a bit, and all references to expires headers are about 10-12 years old, and always mentioning HTML1.0 in the examples. I guess they (the expires headers) were more important then, with dialup connections being fairly common.

And it does have something to do with loading speed, not on the first visit, but by revisits, as all the page elements will be cached if the expies date is set to some date in the far future. Problems would arise, of course, if an image or two or something in the css file, were changed out in the meantime. The old images/css would then be loaded from the browser cache.

Actually, the only new reference to expires headers I found is here:
http://www.webmarketingnow.com/tips/met … ml#expires
This is from 2011 and advises against using them.


That appears to just be for meta expires. I'm using mine in .htaccess
Not sure what the dif is.
Melissa Rhiannon
OS Windows 10
User 126492 Photo


Ambassador
1,525 posts

Enabling mod_deflate can reduce the bandwidth usage on a particular file by up to 70%, but also reduces the maximum load a server can handle and may actually reduce site performance if the site compresses large dynamic files.
It is recommend that dynamic websites that are already CPU limited should be cautious when enabling compression, particularly where it could affect large files.

Not sure why you want to use Expires Headers, for a small site like yours it is more trouble than it is worth. Even if they are used within Meta Tags, Search Engines just ignore them.

At the end of the day, the speed at which a visitor to your site downloads your page depends on the power of their pc system, the speed of the isp they are connecting to the net with and the speed of your hosting service. Don't take the details of the Gtmetrix report too seriously.
Jim
---------------------------

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.