best .htaccess optimization

This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.

Note that these questions will generally not be answered by the administrators of this forum.
Post Reply
wb_user
 
 
Posts: 1099
Joined: Sun Jul 05, 2015 7:03 am

best .htaccess optimization

Post by wb_user »

hi
please give us BEST .htaccess optimization and browser caching FOR WB and static Stites
User avatar
BaconFries
 
 
Posts: 5328
Joined: Thu Aug 16, 2007 7:32 pm

Re: best .htaccess optimization

Post by BaconFries »

Using .htaccess is server related, so you yourself must do this via your host/server as it is not something you can do directly in the software.

For browser cache you can use the following

Code: Select all

<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
wb_user
 
 
Posts: 1099
Joined: Sun Jul 05, 2015 7:03 am

Re: best .htaccess optimization

Post by wb_user »

i use this parameters n my htaccess

# pass the default character set
AddDefaultCharset utf-8
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.website.com [NC]
RewriteRule ^(.*)$ http://website.com/$1 [L,R=301]

RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]

<IfModule mod_expires.c>
ExpiresActive on

# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 month"

# cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest "access plus 0 seconds"

# your document html
ExpiresByType text/html "access plus 0 seconds"

# data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"

# rss feed
ExpiresByType application/rss+xml "access plus 1 hour"

# favicon (cannot be renamed)
ExpiresByType image/x-icon "access plus 1 week"

# media: images, video, audio
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"

# htc files (css3pie)
ExpiresByType text/x-component "access plus 1 month"

# webfonts
ExpiresByType font/truetype "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"

# css and javascript
ExpiresByType text/css "access plus 2 months"
ExpiresByType application/javascript "access plus 2 months"
ExpiresByType text/javascript "access plus 2 months"

<IfModule mod_headers.c>
Header append Cache-Control "public"
</IfModule>

</IfModule>

Header unset Pragma
Header unset ETag
FileETag None

Options All -Indexes

RewriteEngine On
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]

------------------------------------------------------------------------
is this htaccess better or your code ? which one is better?
Post Reply