Advertisement:

Author Topic: Increase your website speed on Apache : .htaccess tweak you could do  (Read 52825 times)

tomshaft

  • Guest
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #15 on: April 05, 2013, 11:17:28 pm »
I've been using the htaccess tweak since late Dec. 2012 and see no problems.
 
 
Tom

darnell

  • Newbie
  • *
  • Posts: 26
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #16 on: May 18, 2013, 02:03:09 am »
Just added this code, thanks the website is loading faster  ;)

Aficionado

  • Guest
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #17 on: May 18, 2013, 02:10:12 am »
Some additional tweaks for .htaccess

1. use PHP 5.3 if you are using 5.2 (usually default on most hosters). For me it is a bit faster.

Code to use in .htaccess on the very top of it (check also with your hoster for the code, maybe it varies from hoster to hoster)

Code: [Select]
# Use PHP 5.3
AddType application/x-httpd-php53 .php
#

2. Use compression in apache www (if your hoster allows it)


Code to use in .htaccess on the very top of it.

Code: [Select]
# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP

I hope i helped

WebSuccess4You

  • Newbie
  • *
  • Posts: 4
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #18 on: June 28, 2013, 09:57:29 pm »
Here is a little tweak you could add to your .htaccess to increase the website speed - (you can locate the .htaccess text file @ the root folder of your installation. If you cant view it - use your legacy file manager, e.g. cPanel ).

ADD the following code to your installed .htaccess
*** do NOT replace the current .htaccess file ***, ADD the following code at the beginning of it :
Code: [Select]
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/css A86400
ExpiresByType text/javascript A86400
ExpiresByType application/x-shockwave-flash A2592000
#
<FilesMatch "\.(gif¦jpe?g¦png¦ico¦css¦js¦swf)$">
Header set Cache-Control "public"
</FilesMatch>
</IfModule>
## EXPIRES CACHING ##

This leverages the cache and increases your site speed.


You can also enable gzip 'ed served content by adding up the following snippet:

Code: [Select]
#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</ifmodule>
#End Gzip

These instructions tell your server to compresse the specified files, decreasing the size of the transferred chunks, hence improving the loading speed but may also increases the server load. Anyway, always test with the great YSlow extension to determine the gain according to your server config, additional improvements, aso..


P.S.  Tweak the .htaccess only if you know what you are doing. Messing up with .htaccess may crash your site.
*** BACKUP YOUR ORIGINAL .htaccess file BEFORE UPLOADING THIS TWEAKED VERSION ***

P.P.S. : Another additional important "speed increasing tip" is given here:
http://doc.osclass.org/Combine_.js_and_.css_files_to_make_OSClass_load_faster

Is this quote CloudFare?   You lost me.  You give all this info then you start debating CloudFare.  What is the connection,please?

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #19 on: August 29, 2013, 07:54:51 pm »
.htaccess mod has nothing to do with CloudFlare service.

Posted above is an Apache server directive that basically tells user's browser how long the cached files remains valid (in seconds if I am not mistaken).

shamim_biplob

  • Full Member
  • ***
  • Posts: 169
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #20 on: October 27, 2013, 12:15:14 pm »
Here is a little tweak you could add to your .htaccess to increase the website speed - (you can locate the .htaccess text file @ the root folder of your installation. If you cant view it - use your legacy file manager, e.g. cPanel ).

ADD the following code to your installed .htaccess
*** do NOT replace the current .htaccess file ***, ADD the following code at the beginning of it :
Code: [Select]
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/css A86400
ExpiresByType text/javascript A86400
ExpiresByType application/x-shockwave-flash A2592000
#
<FilesMatch "\.(gif¦jpe?g¦png¦ico¦css¦js¦swf)$">
Header set Cache-Control "public"
</FilesMatch>
</IfModule>
## EXPIRES CACHING ##

This leverages the cache and increases your site speed.


You can also enable gzip 'ed served content by adding up the following snippet:

Code: [Select]
#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</ifmodule>
#End Gzip

These instructions tell your server to compresse the specified files, decreasing the size of the transferred chunks, hence improving the loading speed but may also increases the server load. Anyway, always test with the great YSlow extension to determine the gain according to your server config, additional improvements, aso..


P.S.  Tweak the .htaccess only if you know what you are doing. Messing up with .htaccess may crash your site.
*** BACKUP YOUR ORIGINAL .htaccess file BEFORE UPLOADING THIS TWEAKED VERSION ***

P.P.S. : Another additional important "speed increasing tip" is given here:
http://doc.osclass.org/Combine_.js_and_.css_files_to_make_OSClass_load_faster


i tried your both code (for cache and gzip) but nothing is working for my site. i check by google page speed.  can you help me?

data99

  • Full Member
  • ***
  • Posts: 180
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #21 on: January 16, 2014, 09:56:53 pm »
I have install osclass to my subdomain and I dont see there .htaccess i see it on my main domain only

default

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/css A86400
ExpiresByType text/javascript A86400
ExpiresByType application/x-shockwave-flash A2592000
#
<FilesMatch "\.(gif¦jpe?g¦png¦ico¦css¦js¦swf)$">
Header set Cache-Control "public"
</FilesMatch>
</IfModule>
## EXPIRES CACHING ##



edit to
 ## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/css A86400
ExpiresByType text/javascript A86400
ExpiresByType application/x-shockwave-flash A2592000
#
<FilesMatch "\.(gif¦jpe?g¦png¦ico¦css¦js¦swf)$">
Header set Cache-Control "public"
</FilesMatch>
</IfModule>
## EXPIRES CACHING ##

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/css A86400
ExpiresByType text/javascript A86400
ExpiresByType application/x-shockwave-flash A2592000
#
<FilesMatch "\.(gif¦jpe?g¦png¦ico¦css¦js¦swf)$">
Header set Cache-Control "public"
</FilesMatch>
</IfModule>
## EXPIRES CACHING ##


is this correct

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #22 on: January 16, 2014, 11:10:36 pm »
It looks to me that your default was already ok.
I am not sure about the subdomains and htaccess, could be that the main one is also auto handled for subdomains but you could copy the htaccess from main to the subdomain(s) root(s).

What I think could be added is the caching of FLV files which, if I am correct, are the videos from YouTube. So if you are using the YouTube plugin you might also want to cache the flv's.

data99

  • Full Member
  • ***
  • Posts: 180
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #23 on: January 16, 2014, 11:29:52 pm »
Yes I have you tube plugin , how do i do that

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #24 on: January 17, 2014, 01:44:56 am »
Add the expiration for the filetype:
ExpiresByType video/x-flv A2592000

You have to add the extension to the ones already there like this:

<FilesMatch "\.(gif¦jpe?g¦png¦ico¦css¦js¦swf¦FLV)$">

Here's interesting YouTube info regarding file formats to consider:
http://productforums.google.com/forum/#!topic/youtube/09SUZOge91s

You could do the same for PDF if you use the printPDF plugin as well but you have to google for the expire def. because i don't know these by head.


Regards,
Eric
« Last Edit: January 17, 2014, 01:56:50 am by SmaRTeY »

Emanuel

  • Newbie
  • *
  • Posts: 6
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #25 on: March 03, 2014, 03:33:02 pm »
Here is a little tweak you could add to your .htaccess to increase the website speed - (you can locate the .htaccess text file @ the root folder of your installation. If you cant view it - use your legacy file manager, e.g. cPanel ).

ADD the following code to your installed .htaccess
*** do NOT replace the current .htaccess file ***, ADD the following code at the beginning of it :
Code: [Select]
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/css A86400
ExpiresByType text/javascript A86400
ExpiresByType application/x-shockwave-flash A2592000
#
<FilesMatch "\.(gif¦jpe?g¦png¦ico¦css¦js¦swf)$">
Header set Cache-Control "public"
</FilesMatch>
</IfModule>
## EXPIRES CACHING ##

This leverages the cache and increases your site speed.


You can also enable gzip 'ed served content by adding up the following snippet:

Code: [Select]
#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</ifmodule>
#End Gzip

These instructions tell your server to compresse the specified files, decreasing the size of the transferred chunks, hence improving the loading speed but may also increases the server load. Anyway, always test with the great YSlow extension to determine the gain according to your server config, additional improvements, aso..


P.S.  Tweak the .htaccess only if you know what you are doing. Messing up with .htaccess may crash your site.
*** BACKUP YOUR ORIGINAL .htaccess file BEFORE UPLOADING THIS TWEAKED VERSION ***

P.P.S. : Another additional important "speed increasing tip" is given here:
http://doc.osclass.org/Combine_.js_and_.css_files_to_make_OSClass_load_faster

Emmanuel

  • Hero Member
  • *****
  • Posts: 645
  • .: ♥ Quality Swiss Details ♥ :. .: Swiss Made :.
Increase your website speed on Apache : .htaccess tweak you could do
« Reply #26 on: March 05, 2014, 02:19:26 am »
Right, the initial original post was an example to complete:

Right, basically, Add **ALL** the types your web server serves: (sounds...relevant  ;))

e.g. for example, add at the top of the .htaccess :
Code: [Select]
AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm

----etc---

Add too the expiration for ALL the filetypes your website hosts:

Code: [Select]
ExpiresByType video/x-flv A2592000
ExpiresByType video/x-ogg A2592000
ExpiresByType video/x-mp4 A2592000

----etc---

Yes, you have to add too the extension to the ones already there:
e.g. for example:
<FilesMatch "\.(ico|css|js|jpe?g|png|gif|swf|flv|mp4|webm|ogv|gz|ttf)$">

i.e. INCLUDING FONTS files if you use fancy ones (big files used on EVERY page!)

don't forget this one:  ???
Code: [Select]
<FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webapp|webm|webp|woff|xml|xpi)$">

you want more? yes? Yes!, a long long list of file extensions?
here you are then    :P
Code: [Select]
<FilesMatch "\.(css|js|htc|CSS|JS|HTC|html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML|ico|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gz|gzip|jpg|jpeg|jpe|gif|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)$">
« Last Edit: March 05, 2014, 02:21:09 am by Emmanuel_WebDev »

Aficionado

  • Guest
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #27 on: March 26, 2014, 06:02:43 pm »
A bit Of Topic but i would like point out that instead of making Apache "faster", just switch to LiteSpeed. Simple as that.

I did 3 months ago.

Diviyah

  • Newbie
  • *
  • Posts: 17
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #28 on: June 17, 2014, 07:08:44 am »
Thanks I feel this improve my classified website http://adzhome.com performance.

Tomyxas

  • Newbie
  • *
  • Posts: 5
Re: Increase your website speed on Apache : .htaccess tweak you could do
« Reply #29 on: September 16, 2014, 10:36:12 am »
Thanks man. This .htaccess trick works  for me. :)