0

This is both a strategy and a technical question, I'm building a web posting mechanism and I will need to store a lot of HTML posts (discussions, comments etc.)

I'm thinking about saving all my HTML posts into database as a ZIP compressed stream (instead of plain text or XML) in order to save space and increase security by encrypting those ZIP data steams, so it will be saved to the database compressed (hopefully close to 90% smaller) and secure. (it does not need to be searchable, I'm going to create the search index myself out of the content of each post)

I want to deliver the ZIP object to the web page/cache and then have the client side unzip the stream and render the HTML that it represent.

This is a Microsoft based MVC web site (c#)

I'm trying to figure out reasons not to do it... other than performance, can anyone pinpoint any other issues with doing something like that?

Also, is there any recommended libraries or built-in ones that I should use for better performance - that both server side and client side can understand (zip and unzip with encryption key/password)?

Thanks in advance.

Yovav
  • 2,557
  • 2
  • 32
  • 53
  • possible duplicate of [JavaScript implementation of Gzip](http://stackoverflow.com/questions/294297/javascript-implementation-of-gzip) – Lorenz Meyer Nov 09 '14 at 13:42

1 Answers1

0

In normal operation, http allows to send the html in a gzipped stream. The webserver compresses the data and sets the corresponding header. The client then unzips transparently.

You simply have to make sure to set the correct header and not have the webserver zip again the already zipped stream.

I see a major drawbacks : You cannot alter the data. That means you cannot add the code for your template nor link between the pages.

I don't think this is a good approach. Store your data as you like and decompress it on the server.

Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121
  • Hi. I don't think you understand... 1. not trying to ZIP the whole page, just the post itself (for example, this comment text or HTML would be a post) 2. I want to save this data to the database, but in a way that it is Zipped and encrypted... make sense? – Yovav Nov 09 '14 at 06:24
  • I understood. But I can see no way how you would unzip on the client other than using the built-in gzip transfer encoding. Unzip in javascript ?! – Lorenz Meyer Nov 09 '14 at 09:07
  • What speaks against unzipping on the server ? – Lorenz Meyer Nov 09 '14 at 09:08
  • I want to use the client resources to unzip... just for better performance, but I'm not sure if with JavaScript I can unzip an encrypted ZIP file/stream... or maybe SQL server has some built-in ZIP options... otherwise I could create a CLR ZIP class... just trying to figure out what would be the best thing to do at this point... – Yovav Nov 09 '14 at 10:35
  • Look at these : http://stackoverflow.com/questions/14620769/decompress-gzip-and-zlib-string-in-javascript https://github.com/beatgammit/gzip-js You could also send the data with ajax, and then you would not need a javascript library. – Lorenz Meyer Nov 09 '14 at 13:35