Classic ASP sessions and to big cookie request size, is that a problem and where to put session variables?
I am using classic ASP 3.0 and each visitor get's many session values when first connected. This way I lower the database connections quite a lot, because I do not need to get variables of the user that I use on most of the pages, on every single page.
I use like session("ID"), session("username"), session("group") etc...
There is no problem, but I found out using Page Speed that my request size is 4.5 KB instead of max 1.5 KB. Now I am not sure if this is a problem in modern browser and what does it mean that every request is 4.5 KB long end every graphics that loads is requested 开发者_如何学Goand the request sent with 4.5 KB? From page speed it would seem so.
So how big a problem is this? And if this indeed is bad practice to put variables that user uses a lot on page in a session, what should I do? Querying database on every page for every user and extracting those values out seems even worse.
Any ideas?
PS - As I've found out, there was something wrong with my Firefox, the session cookies were just building up and I have 121 cookies for my domain?! Now I have cleaned the cookies in FF and all I have is 8 cookies left, which is ok I guess. Thank you both for your tips though!
The session variables are not stored in cookies nor sent with each request and so will not impact on the size of each request/response.
One cookie is used to identify return visitors and re-connect their session, but this will only be a few bytes.
Storing these sorts of user-specific values in session instead of reading from the DB on every request is exactly what Session was designed for, so you're doing the right thing.
Every request and response will be a minimum size regardless of content due to the headers. If you are concerned about request (response?) size you should start investigating other places, such as other cookies for the same domain, IIS default HTTP response headers. Also remember that PageSpeed offers recommendations, not rules carved in stone.
if performance is acceptable then no need to change. Session storage is perfectly acceptable. no need to rewrite application if everything is working.
However, if you want to enhance performance - here are some tips to consider.
25+ ASP Tips to Improve Performance and Style
精彩评论