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.
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.
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.