Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I am writing a PERL program that will use SSI to insert affiliate code into web pages. Here is an example of the source code for a web page using this program:

... surrounding HTML ... <A HREF='http://affiliateprogram.com?id=<!--#include virtual="/cgi-bin +/affiliate.pl?option=50"-->'>Link</A> ... surrounding HTML ... ... surrounding HTML ... <A HREF='http://affiliateprogram.com?id=<!--#include virtual="/cgi-bin +/affiliate.pl?option=50&mainafil=mainaffiliateid"-->'>Link</A> ... surrounding HTML ...

People will link to the page like this:
http://www.mysite.com/page.html?affiliateid. The script affiliate.pl will use the QUERY_STRING and (QUERY_STRING_UNESCAPED || DOCUMENT_ARGS) to determine whether to return the affiliate ID from the DOCUMENT_URI or the one embedded in the "include virtual" tag.

My question is this: Given that the SSI directives could appear quite a few times in a single document, under heavy traffic loads would it be better to execute a single call that would process an entire HTML page using regular epressions to insert the affiliate code in all the right places or to go ahead and let the simple insertion script be run multiple times per page load? The advtantage to a single call is that PERL only has to run once but the script would be much more complex, processing an entire web page that could be anywhere from a few K to 40K+. With the simple SSI insertion, the script needs to be executed again and again but all it does is return a string.

I appreciate any input.

Thanks,
SpaceAce
s>>sp>;s>..|>\u$&ace>g;print;


In reply to Speed consideration by SpaceAce

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-03-29 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found