#1 2016-01-01 13:13:24

chronisvel
Member
Registered: 2016-01-01
Posts: 8

Changes of html views is not reflected in an up and running MVC server

I just created my first MVC server. When I change the html of a view, the changes are not visible in the browser. If I terminate the server and restart the application, changes are visible. I want to be able to change view files without restating the server, what should I do?

Offline

#2 2016-01-08 08:24:57

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Changes of html views is not reflected in an up and running MVC server

I think there is no ready-made methods of doing this.

Sorry, I misread your post and I thought you were talking about auto-reloading without refreshing the browser. AB has given you the correct answer.

Last edited by edwinsn (2016-01-09 03:00:13)


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#3 2016-01-08 17:39:43

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: Changes of html views is not reflected in an up and running MVC server

You should simply disable cache of the templates.

Offline

#4 2016-01-25 20:23:30

chronisvel
Member
Registered: 2016-01-01
Posts: 8

Re: Changes of html views is not reflected in an up and running MVC server

Could you please explain what is the proper way to do it? How can I disable cache of the templates?
For example:
TMVCRunOnRestServer.Create(Self).SetCache('Default',cacheNone,1);
does not work, cache is not disabled.

Offline

#5 2016-02-16 14:55:31

chronisvel
Member
Registered: 2016-01-01
Posts: 8

Re: Changes of html views is not reflected in an up and running MVC server

Please, can you answer my question?
Could you please explain what is the proper way to do it, how can I disable cache of the templates?

Offline

#6 2016-03-14 07:38:18

Chaa
Member
Registered: 2011-03-26
Posts: 245

Re: Changes of html views is not reflected in an up and running MVC server

You can use code like that:

procedure TBlogApplication.Start(aServer: TSQLRestServer);
var
    LParams: TMVCViewsMustacheParameters;
    LViews: TMVCViewsAbtract;
begin
  ...
  inherited Start(aServer, TypeInfo(IBlogApplication));
  FillChar(LParams, SizeOf(LParams), 0);
  // That's key point: check template modification every second
  LParams.FileTimestampMonitorAfterSeconds := 1;
  LParams.ExtensionForNotExistingTemplate := '.html';
  LParams.Helpers := TSynMustache.HelpersGetStandardList;
  LViews := TMVCViewsMustache.Create(Factory.InterfaceTypeInfo, 
    LParams, aServer.LogClass);
  fMainRunner := TMVCRunOnRestServer.Create(Self, nil, '', LViews);
  ...
end;

Offline

Board footer

Powered by FluxBB