Problem
Client was running into an issue where his website pages were taking a really long time to load.

Solution
The following .htaccess code helped me to solve the issue.

#Force non-www:
#RewriteEngine On
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# REDIRECT TO UNDER CONSTRUCTION PAGE
#Options +FollowSymlinks -MultiViews
# Add or remove file types in the next line if necessary.
#RewriteCond %{REQUEST_URI} !\.(css|jpg|png|gif|bmp|js)  [NC]
#RewriteCond %{REQUEST_URI} !under_construction\.html  [NC]
#RewriteRule .*   /under_construction.html [R=302,L]

# prevent directory listings
Options -Indexes
IndexIgnore */*

# follow symbolic links
Options FollowSymlinks
RewriteRule ^admin(/.+)?$ backend/web/$1 [L,PT]
RewriteRule ^(.+)?$ frontend/web/$1
# -----------------------------------------------------------------------
# Compressing output.
# -----------------------------------------------------------------------

    AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
    AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
    AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype


# BEGIN EXPIRES

    # BEGINNING of EXPIRES
    ExpiresActive On
    ExpiresDefault A300
    ExpiresByType text/html A5
    ExpiresByType application/javascript A604800
    ExpiresByType text/css A604800
    ExpiresByType image/x-icon A604800
    ExpiresByType image/gif A604800
    ExpiresByType image/png A604800
    ExpiresByType image/jpeg A604800
    ExpiresByType text/plain A300
    ExpiresByType application/x-shockwave-flash A604800
    ExpiresByType video/x-flv A604800
    ExpiresByType application/pdf A604800
    # END of EXPIRES

# END EXPIRES


    
        Header append Vary Accept-Encoding
    
    
        Header set Cache-Control "max-age=604800, public"
    
    
        Header set Cache-Control "public"
    
    
        Header set Cache-Control "public"
    
    
        Header set Cache-Control "private"
    
    
        Header set Cache-Control "private, must-revalidate"
    



    
    Header set Cache-Control "public"
    Header set Access-Control-Allow-Origin "http://www.stats4stem.org/"



RewriteEngine On
RewriteCond %{REQUEST_URI} !^/m/.*$
RewriteCond %{HTTP_ACCEPT} "text/vnd.wap.wml|application/vnd.wap.xhtml+xml" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT}  "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
#------------- The line below excludes the iPad
RewriteCond %{HTTP_USER_AGENT} !^.*iPad.*$ 
#-------------
RewriteCond %{HTTP_USER_AGENT} !macintosh [NC] #*SEE NOTE BELOW
RewriteRule ^(.*)$ /m/ [L,R=302]

And, I found two websites that analyzed the load time and offered recommended fixes.

The sites are from google and pingdom:
https://developers.google.com/speed/pagespeed/insights/
http://tools.pingdom.com/fpt/

You may also like

Leave a Reply