Saturday, December 22, 2012

Re: New to Django / Web Development [ Confused About When to Store To Database For Static Content]


On Sun, Dec 23, 2012 at 7:43 AM, Django Son <i.ask.django.questions@gmail.com> wrote:
Hi there, :)

I'm a complete beginner at webdev and had a question about when to store to a database for content that seldom changes. I understand the need to access and modify a database for dynamic content but what about static content? For instance, lets say my website has a large number of paragraphs that don't change. Is there a performance benefit for saving these in a database or is it solely for more modularity? When it comes to static content, how do I know the line between when I should save it to a database and when to hard-code it into a template?

Putting the content in a database will usually be slower than just having it on a file, since you have to search a database index, retrieve content over a network connection, and then render that content, as opposed to just reading and rendering a file on disk. 

However, the question isn't really one of performance. If performance becomes an issue, you can always turn to caching (either of database content, rendered page content, or protocol-level caching) to minimise any performance impact.

The bigger question is the use pattern for the content itself. If the content needs to change, who is going to need to change it? What sort of turnaround time are they going to need? And what sort of engineering effort are you willing to spend in order to get that flexibility?

If the content is in a template, only 'expert' developer users are going to be able to change the content, and you're going to need to redeploy your site to make that content go live. However, this is also the simplest solution to build -- edit the content in a template, and you're done. 

If it's in a database, you can put that control in the hands of non-expert users, and let them see the change  immediately. However, you also need to put up a user interface that lets the appropriate non-expert users see and edit that content. This obviously takes more time to develop -- not a huge amount of time, but more than the alternative. 

Whether the engineering effort associated with building a database-backed solution exceeds the annoyance level of needing to manually tweak a template every time a non-expert user wants a change will depend entirely on how often you expect the content to change, how much you want to avoid the distraction, and how annoying your non-expert user base is :-)

I hope that helps shed some light on the problem. 

Yours,
Russ Magee %-)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate