This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Cookies compression & decompression at client side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Cookies compression & decompression at client side" Watch "Cookies compression & decompression at client side" New topic
Author

Cookies compression & decompression at client side

Nalini Nagarathinam
Greenhorn

Joined: Jun 13, 2010
Posts: 16
Hi

I would like to compress and decompress the cookies at client side may be using Javascript.

Kindly let me know you thoughts on the above requirement.

Thanks in advance


Nalini Nagarathinam
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
That's a rather unusual questions. What is the actual problem you're wanting to solve? Are you trying to store too much in cookies? If so, have you considered server-side storage?
vijin das
Ranch Hand

Joined: Jun 07, 2010
Posts: 129

just check this performance related articles ..

performance

generic tutorial


VIJINDAS
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Why would you want to compress just the cookies? This requirement makes no sense. gzip the entire response.
Nalini Nagarathinam
Greenhorn

Joined: Jun 13, 2010
Posts: 16
Thanks to everyone.

Why i need this?

Because i have a search page, to pre-populate the values which users selected(last 10 selection).

Am storing these data in cookie, so that my cookie size is very large. This leads that the request header size is very large size.

hope this will explain my problem.

Regards,

Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
10 user-entered search terms doesn't sound like much - not more than a few hundred bytes for sure - hardly "very large".

You can move the search page into its own path (".../search/..." or something like that), and then use the cookie's path setting to restrict the cookie to just pages in that directory.
Nalini Nagarathinam
Greenhorn

Joined: Jun 13, 2010
Posts: 16
I just gave the example, but we have more data, so that the header size is large.

Any suggestion???
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Lester Burnham wrote:have you considered server-side storage?
Nalini Nagarathinam
Greenhorn

Joined: Jun 13, 2010
Posts: 16
Hi Lester,

Can you please explain about the server side storage?

Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
HttpSession
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Why not just have the server keep an object containing all this information and use a cookie with a unique ID to point to it?

Thats what HttpSessions do but you could roll-your-own version if you don't want to keep sessions.

Bill
Nalini Nagarathinam
Greenhorn

Joined: Jun 13, 2010
Posts: 16
Hi Bill,

As the user hits will be more to the page. we cant keep it in a server. This will lead to performance issue.

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
As the user hits will be more to the page. we cant keep it in a server. This will lead to performance issue.


OH REALLY! - from your vast experience with servlets you have deduced this?

You have made actual measurements?

The experience of countless web sites using the sessions mechanism counts for nothing?

If this data (too large to keep on the server) has to be transmitted with every request, you think it will give better performance than having the server side grab an object from memory or from disk? Better do the numbers before you assert that.

Bill






David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

My original question/solution still hasn't really been addressed: why compress *just* the cookie when you can just compress the entire response?
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

More fundamentally, big cookies are usually a sign of poor design. Cookies are designed to hold a small amount of data. If you want to keep a lot of state, its much better to set the cookie to a random nonce, and use that nonce as the key into a server side hashmap.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cookies compression & decompression at client side
 
Similar Threads
cookie problem
Disabling Cookies
session never expires in javaranch
setting cookies on client machine
session ID changes