Does many include's (in “case”) in ASP classic

2019-07-16 06:26发布

I want to build this page with ASP classic:

<%
Dim depart

depart = 1556


Select Case depart
    Case 1
    %>
    <!--#include virtual="/check/noam/newDesign/test1.asp"-->
    <%
    Case 2
    %>
    <!--#include virtual="/check/noam/newDesign/test2.asp"-->
    <%
    Case 3
    %>
    <!--#include virtual="/check/noam/newDesign/test3.asp"-->
    <%
    Case 4
    %>
    <!--#include virtual="/check/noam/newDesign/test4.asp"-->
    <%
    Case 5
    %>
    <!--#include virtual="/check/noam/newDesign/test5.asp"-->
    <%
    Case 6
    %>
    <!--#include virtual="/check/noam/newDesign/test6.asp"-->
    <%
    Case 7
    %>
    <!--#include virtual="/check/noam/newDesign/test7.asp"-->
    <%
    Case 8
    %>
    <!--#include virtual="/check/noam/newDesign/test8.asp"-->
    <%
End If
%>

And I like to know if the server in the background need to enter to every include or he will enter only to the include in the right case? I need to know that because I like to know if the server will get bad performance with this one.

标签: asp-classic
2条回答
Deceive 欺骗
2楼-- · 2019-07-16 06:31

It really depends on what is inside the includes but I wouldn't expect such a structure to have any observable impact on performance unless you either have 100s of case statements or have 100s of requests per second for the page.

It is true that all the includes will be composed into the script first before code is executed however it should also be remember that the composed and parsed "p-code" version of the final script is cached by ASP.

If the includes are primarly just static HTML content then this approach is actually quite efficient. On the other hand the more inline global identifiers (identifiers not enclosed in Sub, Function or Class) the more time needed to register these identifiers in the Script context (however there would still need to a lot of them to make a noticable difference).

A potential alternative is to use Server.Execute instead of an include. In this case the ASP executed has its own independant script context so it can't share the callers functions and variables (this may or may not be a good thing.) Also its quite possible that Server.Execute will actually turn out slower.

查看更多
ら.Afraid
3楼-- · 2019-07-16 06:54

Includes are loaded before they're executed in classic ASP, so you're basically loading all of these includes, even if they're not executed.

You can use a different pattern: Execute Global, which is the equivalent of using eval() in VB. You read in the file as a string, then execute it. This gets around a cluster of includes but is rather ugly in itself.

查看更多
登录 后发表回答