Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Guides to .htaccess

Asked Modified Viewed 853 times
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Started this discussions
  • Answered 6 questions
asked
Super Admin

I'm posting this guide for your heavy traffic loading site as an optimization to your server loading because I am not bloating default build in .htaccess more than necessary needed for it to work. Introducing more codes into core will only increase support subjects in forum, which I am trying to eliminate. These codes are not going to core and will not be reviewed.

As you have known, we started with CDN technology less than a decade ago. In each website, headers plays a very critical role as to how your website behaves, and if set correctly, can drastically improve your website speed. I personally manage to cut down load times to an instant flash with the following htaccess rules during optimizing the main site load times.

This enable your server to send content as minimum size as it is possible.

<ifmodule mod_deflate.c>
 # Compress HTML, CSS, JavaScript, Text, XML and fonts
 AddOutputFilterByType DEFLATE image/svg+xml
 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/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 MSIE !no-gzip !gzip-only-text/html
 Header append Vary User-Agent
</ifmodule>


Avoid ETAGS if you want your cache control to work properly. Long story short, etags are sent via http requests when a website loads up.
Even if it works, if you are serving lots of smaller files (e.g. images, HTML, javascript files - a typical website in other words), the overhead of making a request to check the status of an etag might not be any faster than not caching at all. This would only be true if the bottleneck is the requests and not the size of the content.

<IfModule mod_headers.c>
 Header unset ETag
</IfModule>
FileETag None



Load once per lifetime for all these files, never expire them ever when in production. Even if some item change its pictures, like a user changing the avatar, the filename will change as well, so it doesn't matter, but never serve the same image again to the same guy, ever, period.

<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|svg|css|map|woff2|swf)(.gz)?$">
 Header set Cache-Control "max-age=31536000, public, immutable"
</FilesMatch>

<IfModule mod_expires.c>
 ExpiresActive on
 ExpiresByType text/css "access plus 1 year"
 ExpiresByType application/javascript "access plus 1 year"
</IfModule>


I'll be tweaking the cache as the new chrome is persistent on showing me them issues after issues during development of this site. If you have any rules set to share, please do share them in this thread.

Regards.
0 replies
There are no post found.

Labels

Statistics

  • Views 0 views
  • Posts 0 posts
  • Votes 0 votes
  • Topic users 1 member

1 participant

C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Started this discussions
  • Answered 6 questions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet