Forum Topic: NSS Ordering Questions
NSS (Not So Simple, hehe, it used to be, but I extendend the context a bit)
Now that Im starting to understand a bit more about .htaccess, I see that basically there are tactics for approaching specific sections in functionality of a site.
Generically speaking, the .htaccess file relates its functionality in 5 main parts (if I understand well): Site Performance, Search Optimization, Site Maintenance, Basic Security, Specific Usability.
So, in order to enhance the functionality of the .htaccess file in regards to starter templates is it better to order accordingly?
This would mean that I could use this ordering in my overall .htaccess file to optimize its functionality, for example ??:
- GSeries Blacklists ← For security (just copied and pasted before following sections)
- Starter template ← For Performance and Optimization, followed by
- Site Specifics ← rewrites and errors for example related to the specific site (Combining this way is ok right?)
What I mean here is the order alters the content delivered right? Even though the .htaccess file rules are completely applied to requests as a whole, it is better practice to control things first before they are delivered right?
(For example before making a rewrite rule make sure the content can be effectively delivered to the client if the request is legitimate???, or are the internal order of directives unnecesary???)
I’m curious becuase I was reviewing an .htaccess file to study it at https://github.com/h5bp/server-configs-apache, and it relates the internal sections a bit differently:
- Permissions
- Errors
- Deliverability
- Security
- Performance
By the way, the mentioned file is big, although I understand that .htaccess by itself has a performance issue, is it correct to say that the bigger the file, the bigger the performance issue?
3 Replies to “NSS Ordering Questions”
Correct, the order in which one includes various types of directives is completely arbitrary in most cases. This is supported by the fact that the Apache website offers no rules or even suggestions regarding such. Whatever makes the most sense to you and your own strategy should work just fine.
As for the size of .htaccess files, I have loaded some sites up with thousands of directives with no noticeable performance impact. Best advice is to aim for simplicity but don’t hesitate to add any rules that you feel are necessary. If you start getting up into thousands and thousands of directives, however, you may encounter issues, depending on the server, software, and other factors.
Ok, if I understand well enough, then directives are applied as cases are presented as rules in the htaccess file, supperseeding the most important (or chief representative of overall applicability).
So I could include for example the site maintenance template at the beggining of my htacces file no matter how big it is (commented with a pound sign) and uncomment temporarily the respective directives when I need to do some sort of maintenance, and it will therefore ignore all other directives that follow since it already gives an order of deliverable objects, then comment with pound again when done with upgrading so the site can be viewed as normal?
Note: this is so I can do the commenting and uncommenting (of the 503 site maintenance) via ssh without having to upload a different htaccess file in FTP mode when updating.
PS.. Hope you understand the question, I dont know why I think so much in spanish lately, thus the ideas come out in that logical reasoning (such a rich language resource).
Yes, you should be able to place the maintenance directives anywhere in the file. Just make sure you test well before going live with the rules. One exception worth mentioning is that, on some servers, rewrite rules, especially those dealing with query strings, may need to precede any other rewrite rules (such as may be used with maintenance redirects). I have found no official documentation on this, but thought I would mention it here as the experience seems relevant. Something to keep an eye on.