File Storage for Blogs – Database vs Filesystem in ASP.NET

asp.netcfile-storagexml

I'm going to develop a fairly basic re-usable blog component, with simple CRUD operations using ASP.Net.

Which method of storing blog posts would be best suited to the situation in terms of performance/maintainability?

  • Create an XML file and store data in filesystem, filesize will not likely be any more than 50kb in size
  • Store blog post data in DB, retrieve as needed

Am I right in assuming that the asp.net runtime will cache the .xml files and only clear them/request a fresh copy when their contents are changed? Or do you have to explicitly add the file to the cache? If this is the case would this offer the best performance over storing the data in the database?

Best Answer

Use a database, thats what they are for. File storage has its place, but I wouldnt use it for this kind of scenario. Consider, for example, getting a list of blog posts containing a certain tag. Doing that with a database is trivial - likely just a single SQL statement. Doing it with files will involve a lot of file manipulation.

Related Topic