On 11 Sep 2006, wrote:
> I've been trying to come up with a way to compress part of a url to
> make it shorter.
>
> Below I have an example of a variable for my url and want it smaller
> sized ascii. I've been trying the Compress:Zlib, however this doesn't
> output ascii.. Any ideas?

On 2006-09-12 03:23, <> wrote:
> wrote:
>> I've been trying to come up with a way to compress part of a url to
>> make it shorter.
>>
>> Below I have an example of a variable for my url and want it smaller
>> sized ascii. I've been trying the Compress:Zlib, however this doesn't
>> output ascii.. Any ideas?
[...]
> Any reason your not passing it as a form variable instead?

What is a "form variable"? Forms can be submitted via GET or POST
requests. In a GET request, the variable becomes part of the URL, in a
POST request it is submitted as part of the body.

So you probably wanted to ask "Any reason not to use POST requests?"

There are a couple of reasons:

1) There is a semantic difference between GET and POST requests. GET
requests are supposed to only retrieve information from the server,
and not to change the server state. Hence they are cacheable and a
browser may automatically repeat them if the result is not in the
cache any more. A POST request is intended change the state of the
server. Hence the browser must sent every request exactly once to the
server.

"" <> wrote:
> Hello,
>
> I've been trying to come up with a way to compress part of a url to
> make it shorter.
>
> Below I have an example of a variable for my url and want it smaller
> sized ascii. I've been trying the Compress:Zlib, however this doesn't
> output ascii.. Any ideas?

use base64 encoding on the compressed data, which might work when the
compression works well. Other, and maybe better option, is using sessions
and using the session id in the URL.

On 11 Sep 2006, wrote:
> Sorry, maybe I was not clear.
>
> My url is actually not 256 char's. It's actually very short, however
> there is encrytped variable data that I would like to shorten.
>
> ie.
> www.testurl.com/script.html?encrypt...uCwEfChCmEmDtDRDlBdBYACBkDYEpEnDoCMAJETEcDxEC
>
>
> So I would like a much shorter encryptedString part
>
> ie
> www.testurl.com/script.html?encryptedString=<40 - 60% shorter then the
> original>

and then on the server save this string with a unique ID in a 2-column
database table. You can use sqlite or something similar if you don't
already have a database server running, and want the operation to be
fast. Just increment the ID when a new string is added.

If you expect lots of strings, prune the database table occasionally
or on a schedule (though this, of course, depends on your setup and
needs).

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!