locked
Database Driven vs Resource files RRS feed

  • Question

  • User1856697911 posted

    Hello,

    i have 2 questions and i wonder if someone could please help me out here.

    1. I am currently upgrading my asp site to .net 2.0. As a multilanguage site, all language text on the pages where stored into a table in my SQL server site database.

    i had a function where i  passed the user's default language value and the text code and reterned the text. However, there where cases where i have15-20 language strings in a page to load, so this means to load a page (apart from other data i need to retrieve from database) there is 15-20 trips to the database to get this text.. And there are quite a few people that use the system.... So you can imagine the stress the database is under..

    Is the use of resource files a better option for me? Will it imporve performance when my site has about 100-150 pages and quite a high  number of users logged on?

    i just want to remove these multiple "trips" to the database in order to retrieve the language data

    2. i know caching is not a topic of this forum, but i tried to test this in order to solve the problem i mentioned above. i used the SQL 2005 cache invalidation option. i add this on my page:

    <%@ Ouputcache duration="5" varybyparam="none" SQLDependency="MyDatabase:Languastringtable">

    The problem is that i have a few links on my page and sometimes, when i click on a link the page does not redirect. Nothing happends.  i have to take off caching or wait a few seconds (for the cache duration to end) and then click on the link.

     

     

     

    Monday, July 24, 2006 7:42 AM

All replies

  • User-1936818034 posted

    In my opinion the resource files is for sure better since they're esay to edit and put much less stress on your server.

    But if you just wanna reduce the trips, why not try storing your text in a different way?

    For example, Store a single text you need for a page in a string such like:
    "Label1.Text=Hello|Label2.Text=World"
    Retrive that string at Page_Load and split it into string[] and then distribute the strings.

    For sql dependency, may I ask what version of sqlserver do you use? If it's not 2005, you have some more step to do besides setting SQLDependency in @OutPutCache~ [;)]

    Wednesday, July 26, 2006 12:01 AM
  • User1856697911 posted

    In my opinion the resource files is for sure better since they're esay to edit and put much less stress on your server.

    Thanks for answering.

    Does this mean though that i have to have a resouce file for each page?

    But if you just wanna reduce the trips, why not try storing your text in a different way?

    For example, Store a single text you need for a page in a string such like:
    "Label1.Text=Hello|Label2.Text=World"
    Retrive that string at Page_Load and split it into string[] and then distribute the strings.

     

    This would be difficult as what do you do, with the other languages? Store each language text in a separate string? That wouldnt be easy

    For sql dependency, may I ask what version of sqlserver do you use? If it's not 2005, you have some more step to do besides setting SQLDependency in @OutPutCache~ [;)]

     

    Yes i use SQL server 2005

    Tuesday, August 1, 2006 4:24 PM
  • User-1936818034 posted

    There are 2 kinds of resource files: global resx is site scope and local resx is for a single page~ I think global resource is somewhat similar to your db solution as any page can access it, but to store page specified resources in local resx file makes the maintenance esaier~

    Here is a sample for comparsion:

    Assume you have a Page.aspx, which have 2 labels: Label1 and Label2, and you have global resx files MyResource.xxxx.resx, and local resource files Page.aspx.xxx.resx ('xxxx' is the language code, e.g en-US)

    Here is the aspx code:

    <asp:Label id="Label1" Text="<%$ Resources:MyResource, Label1Text %>" />
    <asp:Label id="Label2" Text="" meta:resourceKey="Label2" />

    When a request come, asp.net will pick up the lang setting in http header and use the proper resx file.
    And Label1.Text should be a string with resource key: Label1Text in MyResource.xxxx.resx, Label2.Text will be the string with resource key: Label2.Text in Page.aspx.xxxx.resx ~

    Tuesday, August 1, 2006 9:43 PM