WXforum.net
Web Weather => Weather Web Site Help => Topic started by: UpstateWeather.com on July 31, 2018, 09:30:24 AM
-
I've been working on optimizing my site to make it load quicker.
On the speed test sites, it always tells me that I need to Specify a cache validator. Which I have, but it lists out all of the images in the ajax-images and the alert-images file that our scripts / templates use. I can't figure out why those images / folders are not "specifying a cache validator" when I've worked hard (I thought) to ensure my site have the last-modified and ETags.
Any suggestions? Thanks!!
EDIT: Thought this would help. Here's part of my .htaccess file that deals with this:
FileETag MTime Size
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 week"
# cache.appcache needs re-requests in FF 3.6 (HTML5)
ExpiresByType text/cache-manifest "access plus 5 minutes"
# Your document html
ExpiresByType text/html "access plus 5 minutes"
ExpiresByType text/php "access plus 5 minutes"
ExpiresByType text/text "access plus 5 minutes"
ExpiresByType text/txt "access plus 5 minutes"
# Data
ExpiresByType text/xml "access plus 30 minutes"
ExpiresByType application/xml "access plus 30 minutes"
ExpiresByType application/json "access plus 30 minutes"
# RSS feed
ExpiresByType application/rss+xml "access plus 30 minutes"
# Favicon (cannot be renamed)
ExpiresByType image/x-icon "access plus 1 month"
# Media: images, video, audio
ExpiresByType image/gif "access plus 5 minute"
ExpiresByType image/png "access plus 5 minute"
ExpiresByType image/jpg "access plus 5 minute"
ExpiresByType image/jpeg "access plus 5 minute"
ExpiresByType video/ogg "access plus 60 minute"
ExpiresByType audio/ogg "access plus 60 minute"
ExpiresByType video/mp4 "access plus 60 minute"
ExpiresByType video/webm "access plus 60 minute"
# HTC files (css3pie)
ExpiresByType text/x-component "access plus 1 month"
# Webfonts
ExpiresByType font/truetype "access plus 1 year"
ExpiresByType font/opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
# CSS and JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
</IfModule>
<IfModule mod_headers.c>
Header set Connection keep-alive
<FilesMatch "\\.(ico|css|js|sfw)$">
Header set Cache-Control "max-age=13145000, pubic, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
</FilesMatch>
<FilesMatch "\\.(gif)$">
Header set Cache-Control "max-age=300, pubic, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
</FilesMatch>
<FilesMatch "\\.(jpe?g|png|)$">
Header set Cache-Control "max-age=300, pubic, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
</FilesMatch>
<FilesMatch "\\.(x?html?|php)$">
Header set Cache-Control "max-age=60, pubic, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
</FilesMatch>
</IfModule>
-
Edited to add .htaccess file
-
Umm.. you left off the l in the Cache-control header.
Should read:
Header set Cache-Control "max-age=60, public, must-revalidate"
-
Oh..... well I feel real smart right now #-o
Thanks!!! I’ll update it tomorrow and see what happens. Appreciate it Ken!
-
Yep you've plenty of tweaking to do:)
https://gtmetrix.com/reports/www.ericboettner.com/mrMxCf64
-
@saratogaWX - ok so I made that change (adding in the L in public) and it didn't help. I made a few other tweaks to my .htaccess file (below) but they didn't help either. It's just the images in the alerts-image and Ajax-image folders that are giving me the issue, which is odd to me.
@Toxic - so much work to do and I'm so lost.... ](*,)
<IfModule LiteSpeed>
CacheLookup public on
</IfModule>
SetEnv TZ America/New_York
SetEnvIfNoCase ^If-Modified-Since$ "(.+)" HTTP_IF_MODIFIED_SINCE=$1
SetEnvIfNoCase ^If-None-Match$ "(.+)" HTTP_IF_NONE_MATCH=$1
SetEnvIfNoCase ^Cache-Control$ "(.+)" HTTP_CACHE_CONTROL=$1
SetEnvIfNoCase ^Connection$ "(.+)" HTTP_CONNECTION=$1
SetEnvIfNoCase ^Keep-Alive$ "(.+)" HTTP_KEEP_ALIVE=$1
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
SetEnvIfNoCase ^Cookie$ "(.+)" HTTP_MY_COOKIE=$1
<ifModule mod_deflate.c>
<FilesMatch "\.(js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</ifModule>
# TN START ENABLE KEEP ALIVE
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
# TN END ENABLE KEEP ALIVE
# TN – ENABLE LITESPEED CACHE START
<IfModule LiteSpeed>
CacheEnable public
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^GET|HEAD$
RewriteCond %{HTTP_HOST} ^ericboettner.com [NC]
RewriteCond %{REQUEST_URI} !login|admin|register|post|cron
RewriteCond %{QUERY_STRING} !nocache
RewriteRule .* - [E=Cache-Control:max-age=60]
</IfModule>
# TN – ENABLE LITESPEED CACHE END
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 day"
# cache.appcache needs re-requests in FF 3.6 (HTML5)
ExpiresByType text/cache-manifest "access plus 30 minutes"
# Your document html
ExpiresByType text/html "access plus 10 minutes"
ExpiresByType text/php "access plus 10 minutes"
ExpiresByType text/text "access plus 10 minutes"
ExpiresByType text/txt "access plus 10 minutes"
# Data
ExpiresByType text/xml "access plus 30 minutes"
ExpiresByType application/xml "access plus 30 minutes"
ExpiresByType application/json "access plus 30 minutes"
# RSS feed
ExpiresByType application/rss+xml "access plus 30 minutes"
# Favicon (cannot be renamed)
ExpiresByType image/x-icon "access plus 1 month"
# Media: images, video, audio
ExpiresByType image/gif "access plus 30 minutes"
ExpiresByType image/png "access plus 5 minutes"
ExpiresByType image/jpg "access plus 5 minutes"
ExpiresByType image/jpeg "access plus 5 minutes"
ExpiresByType video/ogg "access plus 60 minutes"
ExpiresByType audio/ogg "access plus 60 minutes"
ExpiresByType video/mp4 "access plus 60 minutes"
ExpiresByType video/webm "access plus 60 minutes"
# HTC files (css3pie)
ExpiresByType text/x-component "access plus 1 month"
# Webfonts
ExpiresByType font/truetype "access plus 1 year"
ExpiresByType font/opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
# CSS and JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
</IfModule>
<IfModule mod_headers.c>
Header set Connection keep-alive
Header set Cache-Control "public"
<FilesMatch "\\.(ico|css|js|sfw)$">
Header set Cache-Control "max-age=13145000, public"
Header set Last-Modified "Mon, 31 Aug 2015 00:00:00 GMT"
Header unset Last-Modified
FileETag MTime Size
</FilesMatch>
<FilesMatch "\\.(gif)$">
Header set Cache-Control "max-age=1800, public"
Header set Last-Modified "Mon, 31 Aug 2015 00:00:00 GMT"
Header unset Last-Modified
FileETag MTime Size
</FilesMatch>
<FilesMatch "\\.(jpe?g|png|)$">
Header set Cache-Control "max-age=300, public, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2015 00:00:00 GMT"
Header unset Last-Modified
FileETag MTime Size
</FilesMatch>
<FilesMatch "\\.(x?html?|php)$">
Header set Cache-Control "max-age=60, public, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2015 00:00:00 GMT"
Header unset Last-Modified
FileETag MTime Size
</FilesMatch>
</IfModule>
# TN START GZIP COMPRESSION
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# TN END GZIP COMPRESSION
ErrorDocument 404 http://www.ericboettner.com/404.php
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE image/gif
AddOutputFilterByType DEFLATE image/jpg
AddOutputFilterByType DEFLATE image/jpeg
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/opentype
</IfModule>
# TN – ENABLE MOD PAGESPEED START
# COMBINE CSS, COMPRESS IMAGES, REMOVE HTML WHITE SPACE AND COMMENTS
<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedEnableFilters rewrite_css,combine_css
ModPagespeedEnableFilters recompress_images
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
ModPagespeedEnableFilters collapse_whitespace,remove_comments
</IfModule>
# TN – ENABLE MOD PAGESPEED END
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
-
In case this helps, here's what I'm talking about
The following resources are missing a cache validator. Resources that do not specify a cache validator cannot be refreshed efficiently. Specify a Last-Modified or ETag header to enable cache validation for the following resources:
http://banners.wunderground.com/cgi-bin/banner/ ... atherStationCount&weatherstationcount=KGAMARIE64
https://api.aerisapi.com/oauth2/permissions?cli ... _secret=lXcMtu3rO6271AqeXxCSmQnFA2Q066aDdkIIrEA2
https://api.aerisapi.com/threats/33.995283,-84. ... _secret=lXcMtu3rO6271AqeXxCSmQnFA2Q066aDdkIIrEA2
https://www.ericboettner.com/weather/DualImage.php?i=hi_tsra&ip=20&j=hi_tsra&jp=40
https://www.ericboettner.com/weather/DualImage.php?i=nscttsra&ip=70&j=nscttsra&jp=20
https://www.ericboettner.com/weather/ajax-images//aqi_good_text.gif
https://www.ericboettner.com/weather/ajax-images/FWIFire0.gif
https://www.ericboettner.com/weather/ajax-images/UV10.gif
https://www.ericboettner.com/weather/ajax-images/UV11.gif
https://www.ericboettner.com/weather/ajax-images/UV9.gif
https://www.ericboettner.com/weather/ajax-images/W.gif
https://www.ericboettner.com/weather/ajax-images/falling.gif
https://www.ericboettner.com/weather/ajax-images/flyout-sub.gif
https://www.ericboettner.com/weather/ajax-images/flyout-transparent.gif
https://www.ericboettner.com/weather/ajax-images/moon/w/NH-moon00.gif
https://www.ericboettner.com/weather/ajax-images/moon/w/NH-moon26.gif
https://www.ericboettner.com/weather/ajax-images/raindrop.jpg
https://www.ericboettner.com/weather/ajax-images/rising.gif
https://www.ericboettner.com/weather/ajax-images/sct.gif
https://www.ericboettner.com/weather/ajax-images/spacer.gif
https://www.ericboettner.com/weather/ajax-images/wr-SW.png
https://www.ericboettner.com/weather/ajax-images/wr-W.png
https://www.ericboettner.com/weather/ajaxWDwx3.js
https://www.ericboettner.com/weather/ajaxgizmo.js
https://www.ericboettner.com/weather/alert-images/A-none.png
https://www.ericboettner.com/weather/forecast/images/nbknfg.jpg
https://www.ericboettner.com/weather/forecast/images/ntsra10.jpg
https://www.ericboettner.com/weather/forecast/images/ntsra50.jpg
https://www.ericboettner.com/weather/forecast/images/ra10.jpg
https://www.ericboettner.com/weather/forecast/images/sctfg.jpg
https://www.ericboettner.com/weather/images/nohazards.png
https://www.ericboettner.com/weather/raintoday.gif
https://www.ericboettner.com/weather/weather-screen-css2018-narrow.css
https://www.ericboettner.com/weather/webcamsmall.jpg
https://www.googletagmanager.com/gtag/js?id=UA-101597709-1
-
I'm interested in how this turns out for you as I'm trying to speed up my own site and have similar warnings as you.
Question: is the .htaccess file supposed to already be there or did you have to create it? I can't find it at all, not in the root of the Domain (where it's supposed to be), or in the public_html folder. There are a number of other .xxxx hidden files, but not this one.
-
@saratogaWX - ok so I made that change (adding in the L in public) and it didn't help. I made a few other tweaks to my .htaccess file (below) but they didn't help either. It's just the images in the alerts-image and Ajax-image folders that are giving me the issue, which is odd to me.
@Toxic - so much work to do and I'm so lost.... ](*,)
Is your .htaccess file hidden and called ".htaccess"
is it placed into the correct folder. the one when your index.php is from this URL
https://www.ericboettner.com/weather/index.php
-
@saratogaWX - ok so I made that change (adding in the L in public) and it didn't help. I made a few other tweaks to my .htaccess file (below) but they didn't help either. It's just the images in the alerts-image and Ajax-image folders that are giving me the issue, which is odd to me.
@Toxic - so much work to do and I'm so lost.... ](*,)
Is your .htaccess file hidden and called ".htaccess"
is it placed into the correct folder. the one when your index.php is from this URL
https://www.ericboettner.com/weather/index.php
Hi Toxic - yes, it's called .htaccess and not accessible by the browser. It's in the "weather" folder where my index.php page is.
-
<IfModule mod_headers.c>
Header set Connection keep-alive
<FilesMatch "\\.(ico|css|js|sfw)$">
Header set Cache-Control "max-age=13145000, pubic, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
</FilesMatch>
<FilesMatch "\\.(gif)$">
Header set Cache-Control "max-age=300, pubic, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
</FilesMatch>
<FilesMatch "\\.(jpe?g|png|)$">
Header set Cache-Control "max-age=300, pubic, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
</FilesMatch>
<FilesMatch "\\.(x?html?|php)$">
Header set Cache-Control "max-age=60, pubic, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
</FilesMatch>
</IfModule>
replace above exactly what i use might help no guarantee do back up your original .. make sure htaccess is in the root directory of server.
<IfModule mod_headers.c>
Header append Cache-Control "public"
</IfModule>
# Cache any images for one year
<filesMatch ".(png|jpg|jpeg|gif|svg)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
# Cache any CSS and JS files for a month
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>
-
<IfModule mod_headers.c>
Header set Connection keep-alive
<FilesMatch "\\.(ico|css|js|sfw)$">
Header set Cache-Control "max-age=13145000, pubic, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
</FilesMatch>
<FilesMatch "\\.(gif)$">
Header set Cache-Control "max-age=300, pubic, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
</FilesMatch>
<FilesMatch "\\.(jpe?g|png|)$">
Header set Cache-Control "max-age=300, pubic, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
</FilesMatch>
<FilesMatch "\\.(x?html?|php)$">
Header set Cache-Control "max-age=60, pubic, must-revalidate"
Header set Last-Modified "Mon, 31 Aug 2009 00:00:00 GMT"
</FilesMatch>
</IfModule>
replace above exactly what i use might help no guarantee do back up your original .. make sure htaccess is in the root directory of server.
<IfModule mod_headers.c>
Header append Cache-Control "public"
</IfModule>
# Cache any images for one year
<filesMatch ".(png|jpg|jpeg|gif|svg)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
# Cache any CSS and JS files for a month
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>
Thanks for sending me your suggested code - unfortunately it didn't work. I'm going to keep digging and figure out what's causing it -I'm sure it's an error on my part.
-
have a look here for a few suggestions of htaccess issues, http://smartwebdeveloper.com/apache/htaccess-problems
Also is mod_rewrite enabled
-
hmmm interesting this works on many and is the simplest way to ensure , however you may want to look at the structure of your htaccess are the expires at the very bottom...
example
<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 month”
ExpiresByType application/pdf “access 1 month”
ExpiresByType application/javascript “access 1 month”
ExpiresByType application/x-javascript “access 1 month”
ExpiresByType application/x-shockwave-flash “access 1 month”
ExpiresByType image/x-icon “access 1 year”
ExpiresDefault “access 7 days”
</IfModule>
i spent months fine tuning the htaccess nothing was immediate lots of trial and and error and lots of reading . now use same file on other setups . good luck you will nail it sooner or later
-
hmmm interesting this works on many and is the simplest way to ensure , however you may want to look at the structure of your htaccess are the expires at the very bottom...
example
<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 month”
ExpiresByType application/pdf “access 1 month”
ExpiresByType application/javascript “access 1 month”
ExpiresByType application/x-javascript “access 1 month”
ExpiresByType application/x-shockwave-flash “access 1 month”
ExpiresByType image/x-icon “access 1 year”
ExpiresDefault “access 7 days”
</IfModule>
i spent months fine tuning the htaccess nothing was immediate lots of trial and and error and lots of reading . now use same file on other setups . good luck you will nail it sooner or later
I'll check in a few if it's at the bottom of the .htaccess or not, but are you saying it SHOULD be? Or at least, that's how you have it?