Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 25, 2012, 11:22:03 AM

Pages: [1]   Go Down
  Print  
Author Topic: htaccess question server speed, gzip, and using cache  (Read 2744 times)
durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« on: January 07, 2010, 09:11:10 PM »

I have been told that i need to use this htaccess to inprove response time and also for less server strain on LP  

is it safe to use and will it help you think... seems to be some talk about gzip not sure if it applies to LP or not..

do you see any potential security risk here.



it comes in three parts.

part 1

Let’s start with content compression. It is generally a good idea to compress everything except the binary data. The following code will handle all the compression related stuff. It will also check for old browsers not supporting compression and will act accordingly.

Code:
# Below uses mod_deflate to compress text files. Never compress binary files.  

02 <IfModule mod_deflate.c>  

03 SetOutputFilter DEFLATE  

04 # compress content with type html, text, js, and css  

05 AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/javascript application/x-javascript  

06 <IfModule mod_headers.c>  

07 # properly handle requests coming from behind proxies  

08 Header append Vary User-Agent  

09 </IfModule>  

10 </IfModule>  

11    

12 # Properly handle old browsers that do not support compression  

13 <IfModule mod_deflate.c>  

14 BrowserMatch ^Mozilla/4 gzip-only-text/html  

15 BrowserMatch ^Mozilla/4\.0[678] no-gzip

16 BrowserMatch \bMSIE !no-gzip !gzip-only-text/html  

17 # Explicitly exclude binary files from compression just in case  

18 SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|pdf|swf|ico|zip)$ no-gzip

19 </IfModule>


part 2


Next, we will instruct the browser to cache the files which won’t be changing regularly. This way, browsers will utilize the copy they already have. A lot of bandwidth and time can be saved with this setting.


Code:
# Set long expire headers for better browser caching  

02 <IfModule mod_expires.c>  

03 ExpiresActive On  

04 ExpiresByType text/css "access plus 30 days"

05 ExpiresByType text/javascript "access plus 7 days"

06 ExpiresByType application/x-javascript "access plus 7 days"

07 ExpiresByType application/javascript "access plus 7 days"

08 ExpiresByType image/x-icon "access plus 7 days"

09 ExpiresByType image/vnd.microsoft.icon "access plus 7 days"

10 ExpiresByType image/png "access plus 30 days"

11 ExpiresByType image/gif "access plus 30 days"

12 ExpiresByType image/jpeg "access plus 30 days"

13 ExpiresByType image/jpg "access plus 30 days"

14 ExpiresByType application/x-shockwave-flash "access plus 30 days"

15 </IfModule>


part 3

We will also turn off ETags and force the browser to rely on our cache control settings above.


Code:
Header unset ETag  

2 FileETag None
Logged
jimlongo
Intergalactic Superstar
*****
Offline Offline

Posts: 147



WWW
« Reply #1 on: January 08, 2010, 05:56:49 AM »

As to Part 1 it's not available

http://www.lunarforums.com/lunarpages_review_and_feedback/any_reason_theres_no_moddeflate_or_modgzip_available-t53945.0.html
Logged

DEddleman
Spacescooter Operator
*****
Offline Offline

Posts: 34


Elite!


« Reply #2 on: January 08, 2010, 07:49:26 AM »

mod_deflate's benefits are largely minimal, too, especially when they're offset by the highly increased CPU usage driven by the compression. It's only useful if you're going to be sending out downloads to people. Otherwise for common text & images the actual compression is minimal as most text does not compress well nor do most web-friendly image formats (GIF/JPEG).
Logged

Pages: [1]   Go Up
  Print  
 
Jump to: