Skip to main content
BreakawayPaul
Inspiring
April 29, 2015
Answered

caching variables?

  • April 29, 2015
  • 2 replies
  • 493 views

I've been on a mission to optimize things in our web template, and I've been using a lot of query caching with fantastic results.

One place I think can be improved is variable assignment.  We assign several variables that use CGI.SCRIPT_NAME, and I'm not sure how resource intensive that is.  I'm wondering if I can use cfcache to server-cache these variables to keep them from having to be set on each page request, but the documentation on that tag isn't great.

Does anyone here have any insight or guidance?

Thanks!

    This topic has been closed for replies.
    Correct answer CutterBl

    CGI.SCRIPT_NAME is a request level item. This is a variable returned by your web server that gives the path of the page being requested, so caching this would not be a good idea.

    I have a multi-part series on my blog on updating legacy applications, with a succession of posts that talk about scope assignments that may be beneficial to your refactoring.

    2 replies

    BKBK
    Community Expert
    Community Expert
    May 2, 2015

    It makes sense to cache CPU-intensive resources, for example, the result of a query, of an HTTP call or of a complex evaluation. You will get no benefit by caching CGI.SCRIPT_NAME. It is basically a constant, whose evaluation costs negligible CPU resources.

    CutterBlCorrect answer
    Inspiring
    May 1, 2015

    CGI.SCRIPT_NAME is a request level item. This is a variable returned by your web server that gives the path of the page being requested, so caching this would not be a good idea.

    I have a multi-part series on my blog on updating legacy applications, with a succession of posts that talk about scope assignments that may be beneficial to your refactoring.

    BreakawayPaul
    Inspiring
    May 4, 2015

    Cool! Thanks everyone.

    The main reason I asked about this is because we have a lot of pages that seem to lag for no good reason (and we also have unexplained random server crashes), and upon inspection of some of these pages (written by people who are now long-gone), I've found things like multiple, redundant expandpath() functions, and recoding these pages has helped a lot (with the speed, not the server crashes).

    So I'm looking for improvements wherever I can get them.