How much does using htaccess files slow down website performance (especially with solid state disks)?

后端 未结 6 1011
盖世英雄少女心
盖世英雄少女心 2020-12-15 04:38

The Apache docs say (http://httpd.apache.org/docs/2.4/howto/htaccess.html),

\"You should avoid using .htaccess files completely if you have access t

6条回答
  •  醉梦人生
    2020-12-15 05:15

    It is hard to give numbers as the impact depends on the speed of your hardware and how much memory are you willing to dedicate for file caching, but let me give you an example that should clarify the impact - let say you have a wordpress site and an image which is located at /wp-content/uploads/2015/10/my.png needs to be served.

    While serving this file might take 1 disk access, just to check out for all the possible .htaccess you will need additional 5 disk accesses. If the file is big the overhead might not be noticeable, but for a small file that might even fit into one block on the disk you waste 80% of the time doing things that are not needed at all.

    Still, big enough cache can fix almost any design/coding problem, but the more directories you will have the bigger the cache that you will need to avoid degradation of performance.

    In your specific case it is actually a no brainer at all. You already generate the htaccess files so all you need to do is wrap them in a directory directive, generate them into some directory and include them from http.conf. Even doing it manually should not take more then a few hours and after that you have a better architecture of your server.

提交回复
热议问题