For my ASP.NET based application, I have a sizable amount of javascript
that needs to be downloaded to the browser on each page. This
javascript code is user-specific.
I want to minimize the amount of code downloaded to the browser and the
impact on my webserver. Since the page is user-specific and does
not change for the session, I would like to be able to generate the
script once, download it to the browser, and subsequent references to
the Javascript would be referenced locally.
The thought here is I would have an SRC link that is generated per user - looking something like this:
<script language=javascript src=CodeGen.aspx?id=fkj23kj>ShowMenu();</script>
Each page within the application would contain the CodeGen reference
with the id being assigned at the session level for the user. The
first time the browser hits this reference, it goes out to the
CodeGen.aspx file and generates the appropriate code. On
subsequent calls, the browser recognizes the cached script file and
uses it.
There are things I can do to cache the script and download it each
time, I don't have a problem with that. However, given the
roughly static nature of this file I'd like to avoid the download time
to the browser (and bandwidth/processor usage). I'm also hoping
to avoid setup issues (i.e. registering mime types, modifying
web.config, etc.) as much as possible. But we'll see if that's
feasible.
I'll blog these bits as I proceed on a solution. Any feedback is welcome.