RickStrahl / Westwind.Globalization

Database driven resource localization for .NET applications
544 stars 135 forks source link

Reload Resources only works first time #153

Closed erviem99 closed 5 years ago

erviem99 commented 5 years ago

Hello!

I integrated the Localization Administration interface into my ASP.Net MVC application and I pull the localized strings from a table in a SQL Server.

When I invoke the editor from my application and make som changes I force a reload in my MVC application using the "Reload Resources" button in the administration interface.

My issue is that this only work the first time!

After the first reload any new changes is not picked up by my application until I restart the application.

Any hint of what is going on here is much appreciated.

Regards, Erik

erviem99 commented 5 years ago

After some investigating I found that this is probabely caused by Angular caching in localizationservice.js:

    function reloadResources() {
        return $http.get("localizationService.ashx?method=ReloadResources")
             .error(parseHttpError);
    }

Is anyone else seeing this?

RickStrahl commented 5 years ago

No, it works for me I can hit that to reload resources with no issues. But caching could be a problem. Can you try using the dev tools to disable the cache and see if that works then? If so maybe there's an agressive cache policy set on your server/machine. I suppose we should force a cache clear or add a cache buster string to the end of the url.

Try:

return $http.get("localizationService.ashx?method=ReloadResources&t=" + new Date().getTime() )
erviem99 commented 5 years ago

Thanks, Your fix solved my problem.

I was able to reproduce the issue on an empty ASP.Net MVC project (VS 2017).

Cache-control in the response header is set to "private".

RickStrahl commented 5 years ago

Added on this end as well.