Web Hosting Talk







View Full Version : Looking to store code for web pages in external source


Nullified
02-06-2005, 01:41 PM
I have several pieces of code that are exactly the same on mutiple pages of my site and I would like to store the multiple lines of code in an external source such as mysql or another file and include the source in my documents. This way I will only need to change the code once and it will span across all my pages. By utilizing php's include method I could make the original requested webpage much smaller, however if the included code is within another file the total download process will still be larger then wanted. Thus, I was thinking of using mysql to store the code as I assume it would be faster for the user and less of a download. Am I correct? If so what kind of database/table would I need to store the code in to ensure proper spacing of the code? Sorry, but I'm not that fluent with mysql atm. If any experts can give me some feedback on this I wold greatly appreciate it. Is what I'm doing even worth it as far as performance for visitors?

ilyash
02-06-2005, 01:48 PM
It would be the same i think.
Actually the file system would be better.
Mysql has to read the file off the hard disk, parse it in some way and then send it to your program.

The flat file just gets read.
The only time it would take would be the time it takes to read off the hard drive, which mysql takes that time too...

The performance time would be so negligible that users would have the same download time.
Think about it...

DOCUMENT A - 5 kb [file stored somewhere]

DOCUMENT B - 5 kb [main file with include or MYSQL]

DOCUMENT C - 5 kb [stored in mysql]

If you use file system..
you have DOC B + A = 10kb
if you use mysql system
DOC B + C = 10kb

so the user downloads the same amount either way.

hope that helps.

Nullified
02-06-2005, 02:10 PM
True, file system may be better because the server doesn't have to process any sql.