Page 1 of 1
About storing encoded HTML in database
Posted: Thu Jun 05, 2008 1:05 am
by parka
Is there any difference between storing pure HTML and encoded HTML into databases?
E.g. Storing <script> vs <script>
They will be properly sanitized before inserting into the database.
When printing on a webpage, the <script> will be properly encoded to <script>.
And of course, the <script> doesn't need additional encoding.
Re: About storing encoded HTML in database
Posted: Thu Jun 05, 2008 8:52 am
by vargadanis
If you want to render the HTML code which you store in the database it is easier to store the pure tags with no HTML special chars. IF you wish only to display it than use the encoded one. There will be no way the browser will render such codes.
Re: About storing encoded HTML in database
Posted: Thu Jun 05, 2008 2:39 pm
by Benjamin
To save space I would store the original or decoded html AND I would use
bzcompress() to compress it.
Re: About storing encoded HTML in database
Posted: Thu Jun 05, 2008 3:25 pm
by onion2k
astions wrote:To save space I would store the original or decoded html AND I would use
bzcompress() to compress it.
Adding a few hundred gigabytes to your server is easy and cheap. Upgrading the CPU/memory if you're overloading it isn't so simple. Therefore it makes more sense to store big things that take little effort to send to the user.
Re: About storing encoded HTML in database
Posted: Thu Jun 05, 2008 4:00 pm
by Benjamin
That makes sense but I don't think it's correct. I would have a look at
http://web.cecs.pdx.edu/~len/compression.pdf
Data Compression and Database Performance wrote:
In a simple performance comparison, we have seen that for data sets larger than memory
performance gains larger than the compression factor can be obtained because a larger fraction of
the data can be retained in the workspace allocated to a query processing operator. For a
compression factor of two, we observed performance gains of factor three and more.
Re: About storing encoded HTML in database
Posted: Fri Jun 06, 2008 7:47 am
by vargadanis
And I would not consider the server side as importan as the clientside. Even if you have to upgrade both the CPU and the Memory and also the disk space but you gain significatn boost to the user experience, it is the way to go. The satisfied user is the best ad to you, isn't it?