Author Topic: Once again lets make your website a better user experience  (Read 3914 times)

0 Members and 1 Guest are viewing this topic.

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Once again lets make your website a better user experience
« Reply #25 on: August 25, 2017, 07:40:32 AM »
Now that I have modified my .htaccess file to "cache" these files, where can I check to see if they are really being cached to my local machine rather than retrieving from file server?

Jim
Go to your website , example below is Chrome
Right Click somewhere in the heading, choose inspect
Bottom part changes
Hit the refresh page in the address area (round arrow)
In the bottom part you can now see  if the files come from your server, memory cache, disk cache a.s.o.

The attached screen-shot shows that Chrome is loading most parts of your page from the cache.

Wim
P.s. you can see errors on your pages when you click  the console-tab
« Last Edit: August 25, 2017, 07:42:33 AM by wvdkuil »

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1019
    • Southern Maryland Weather
Re: Once again lets make your website a better user experience
« Reply #26 on: August 25, 2017, 07:50:41 AM »
Awesome! Looks like its working...

thanks for all your inputs...

Jim

Offline Bunty

  • Forecaster
  • *****
  • Posts: 2432
  • Stillwater, home of Oklahoma State University
    • Welcome to Stillwater Weather
Re: Once again lets make your website a better user experience
« Reply #27 on: September 06, 2017, 01:59:28 PM »
good info here..

Is there a way to cache certain files with wildcards? I.E, I have a menu system with GIFS that will ALWAY be used and could be cached. The GIF names are:

somdwx_m1bg0.gif
somdwx_m1bg1.gif
somdwx_m1bg2.gif
somdwx_m1bg3.gif
somdwx_m1bg4.gif


Jim

if your confident and understand the .htaccess  file and its consequences when it goes wrong ..

#30 days
<Files “somdwx_m1bg0.gif”>
  ExpiresActive On
  ExpiresDefault A2592000
</Files>



#1 year 365 days
<Files “somdwx_m1bg0.gif”>
  ExpiresActive On
  ExpiresDefault A31536000
</Files>

it is best to do some research ..

brian..

Is there a more efficient way to specify more than one image so that </Files> only has to be used once?  Let's not let the browser read the .htaccess longer than necessary.

Also the 2nd home page using modified AltDashboard 6.95 at http://stillwaterweather.com/2ndhome.php

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1019
    • Southern Maryland Weather
Re: Once again lets make your website a better user experience
« Reply #28 on: September 06, 2017, 02:20:58 PM »
yes. can use wildcards...

Offline Bunty

  • Forecaster
  • *****
  • Posts: 2432
  • Stillwater, home of Oklahoma State University
    • Welcome to Stillwater Weather
Re: Once again lets make your website a better user experience
« Reply #29 on: September 27, 2017, 12:07:58 AM »
yes. can use wildcards...

I don't understand how to do wildcards as well as some of the other operations.  I did speed up my front page to some extent by switching to a web cam source that does still, rather than moving images.  For the source code, I updated ancient attributes to get it compliant with HTML5.   Some tables had to go and were converted to div.  It slimmed things down some for a little greater speed.  Getting rid of cellspacing and cellpadding attributes helped.  Some experts say all tables should go and use div, instead, even for tabular data.  But important to learn CSS and DIV coding for that.

For gtmetrix, I'm still well down from the 90s.  But don't understand how to do the more arcane stuff, such as how to make a cookieless domain, css sprites and avoid URL redirects.   But fully loaded time on my front page can be as little as 2.1s.  Around 1s would be preferable but surely difficult for well detailed weather pages.

Also the 2nd home page using modified AltDashboard 6.95 at http://stillwaterweather.com/2ndhome.php

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1019
    • Southern Maryland Weather
Re: Once again lets make your website a better user experience
« Reply #30 on: November 13, 2017, 01:56:29 PM »
Hi All,

 I have implemented the cache control directive in my .htaccess file but some of the images are still not being cached.

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access 1 week"
    ExpiresByType text/html "access 1 week"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType text/x-javascript "access 1 week"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresByType image/x-icon "access 1 year"


   <FilesMatch "\somd_banner.png$">
    ExpiresActive On
    ExpiresByType image/png "access plus 1 year"
   </FilesMatch>

   <FilesMatch "\mail.png$">
    ExpiresActive On
    ExpiresByType image/png "access plus 1 year"
   </FilesMatch>

   <FilesMatch "\Twitter.png$">
    ExpiresActive On
    ExpiresByType image/png "access plus 1 year"
   </FilesMatch>

   <FilesMatch "\Facebook.png$">
    ExpiresActive On
    ExpiresByType image/png "access plus 1 year"
   </FilesMatch>

   <FilesMatch "\adbanner.png$">
    ExpiresActive On
    ExpiresByType image/png "access plus 1 year"
   </FilesMatch>

   <FilesMatch "\school-bus-1.jpg$">
    ExpiresActive On
    ExpiresByType image/jpeg "access plus 1 year"
   </FilesMatch>

   <FilesMatch "\wrn1.jpg$">
    ExpiresActive On
    ExpiresByType image/jpeg "access plus 1 year"
   </FilesMatch>

   <FilesMatch "\winter_weather.jpg$">
    ExpiresActive On
    ExpiresByType image/jpeg "access plus 1 year"
   </FilesMatch>

  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

Offline weather34

  • Forecaster
  • *****
  • Posts: 1068
    • https://weather34.com/homeweatherstation
Re: Once again lets make your website a better user experience
« Reply #31 on: November 13, 2017, 04:08:33 PM »
check  IfModule mod_expires.c is present and if it has something like below it could be overriding any specific individual files your try to cache

ExpiresByType image/gif A604800

ExpiresByType image/png A604800

ExpiresByType image/jpeg A604800

can you explain <FilesMatch "\winter_weather.jpg$"> the dollar character purpose at the end of the jpg etc not seen this b4 so i may learn something new


simplified your
<Files "somd_banner.png">
  ExpiresActive On
  ExpiresDefault A31556952
</Files>

examples    A(value) is seconds

ExpiresDefault A31556952

ExpiresDefault A2592000 = 1 month

ExpiresDefault A604800= 1 week

ExpiresDefault A86400 =1 day

ExpiresDefault A60 = 60 seconds

unfortunately i dont use the specific image method so you may have to go through a bit of trial and error . i just cache the file extensions like svg etc..


brian

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1019
    • Southern Maryland Weather
Re: Once again lets make your website a better user experience
« Reply #32 on: November 13, 2017, 05:00:40 PM »
Thanks!

The "$" tells that it's and EOL (end of line).

Jim

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1019
    • Southern Maryland Weather
Re: Once again lets make your website a better user experience
« Reply #33 on: November 14, 2017, 11:16:24 AM »
Is there a way to cache anything out of one specific directory.

I.E., all the forecast images could be cached..  "/forecast/images/*.jpg"

Jim

Offline ConligWX

  • Forecaster
  • *****
  • Posts: 840
  • #conligwx
    • conligwx.org
Re: Once again lets make your website a better user experience
« Reply #34 on: November 14, 2017, 06:47:48 PM »
Is there a way to cache anything out of one specific directory.

I.E., all the forecast images could be cached..  "/forecast/images/*.jpg"

Jim

if your running PHP 7 you may also have zend opcache running.

you can then blacklist files from being cached too.
Regards Simon
Davis Vantage Pro2 Plus (6162UK) • Daytime FARS • WeatherLink Live • AirLink • PurpleAir PA-II-SD • CumulusMX •


Offline weather34

  • Forecaster
  • *****
  • Posts: 1068
    • https://weather34.com/homeweatherstation
Re: Once again lets make your website a better user experience
« Reply #35 on: November 15, 2017, 06:25:57 AM »
i guess the other way would be create a separate htaccess file and place it in the image folder you wish to cache . just have a limited functional htccess for that folder. try it see no reason why it wouldnt work and it will cache that file with the values you added. trial and error ..

<IfModule mod_headers.c>
    #Header set Cache-Control "max-age=31536000"
    Header unset Cache-Control
    Header unset ETag
    FileETag none
</IfModule>

<IfModule mod_expires.c> 
    ExpiresActive On
    ExpiresDefault "now"
       <Files "/path/imagefolder/*.jpg">
      ExpiresDefault "access plus 1 month"
    </Files>
   
</IfModule>

 

anything