#1 2017-05-02 13:52:40

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Turn MVC View Caching in DEBUG mode off

Hi AB,

is it possible to turn the Caching of Default.html / partial FIles off. To easier test Modifications done to the files ?
I can not find any setting for this.

BR


Rad Studio 12.1 Santorini

Offline

#2 2017-05-09 06:53:00

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: Turn MVC View Caching in DEBUG mode off

we are writing a bigger mvc service atm.
the develop workflow is not optimal cause of caching in mvc.

example:

1. write some delphi code
2. start debugger
3. look at pages and change some of the html/partial
4. reload in browser does show cached site
5. stop debugger
6. start debugger
7. reload browser (Sometimes have to relog)
8. look at new site
9. repeat at 3.

i think steps 3 to 9 could be faster 5,6 take a lot time if cache could be turned off. i would program it but don't know where.
br


Rad Studio 12.1 Santorini

Offline

#3 2017-05-09 08:11:23

oz
Member
Registered: 2015-09-02
Posts: 98

Re: Turn MVC View Caching in DEBUG mode off

Hi,
did you have a look at TMVCRunWithViews.SetCache? Looks like a good starting point for further investigation...
Cheers, oz.

Offline

#4 2017-05-10 10:44:08

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: Turn MVC View Caching in DEBUG mode off

Hi oz,
ty for your comment - but it is not the solution.

But i found and programmed one that fits for me atm.
first: The HTML Cache can be enabled and disabled with TMVCViewsMustacheParameters.FileTimestampMonitorAfterSeconds we had it set to 0 which enables the cache. Setting it to higher value than 0 lets mvc view control the file age and then reload if neccessary.

second: the partial files are loaded completely in memory on View initialization in TMVCViewsMustache.Create, there is a variable called fViewPartials which holds the partials.
here is no predefined option to disable it nor is the file age controlled.
I hard coded a reload of the partial files in DEBUG - Mode

SynMustache.pas:

  TSynMustachePartials = class
  protected
    fList: TRawUTF8ListHashed;
    fOwned: boolean;
    function GetPartial(const PartialName: RawUTF8): TSynMustache;
{$if defined(DEBUG)}
  public
    fViewPartialFolder : RawUtf8;
{$endif}
  public

....

function TSynMustachePartials.GetPartial(
  const PartialName: RawUTF8): TSynMustache;
var i: integer;
begin
  if self=nil then begin
    result := nil;
    exit;
  end;
  i := fList.IndexOf(PartialName);
  if i<0 then
    result := nil else
{$if defined(DEBUG)}
    result := TSynMustache.Parse(AnyTextFileToRawUTF8(fViewPartialFolder+PartialName+'.partial', true));
{$else}
    result := TSynMustache(fList.Objects[i]);
{$endif}
end;

mORMotMVC:

...
  // get partials
  fViewPartials := TSynMustachePartials.Create;
{$if defined(DEBUG)}
  fViewPartials.fViewPartialFolder := fViewTemplateFolder;
{$endif}
  if FindFirst(fViewTemplateFolder+'*.partial',faAnyFile,SR)=0 then
...

Last edited by itSDS (2017-05-10 10:45:22)


Rad Studio 12.1 Santorini

Offline

#5 2017-05-24 04:42:42

Joker
Member
Registered: 2015-07-06
Posts: 15

Re: Turn MVC View Caching in DEBUG mode off

Thanks itSDS for that solution ... I was looking for a way to do that.

Last edited by Joker (2017-05-24 04:42:59)

Offline

#6 2020-05-21 15:04:57

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Re: Turn MVC View Caching in DEBUG mode off

Isn't there an easier way to disable cache?

I don't like modifying the original code but when debugging the cache is annoying.

Offline

#7 2020-12-15 18:19:23

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Re: Turn MVC View Caching in DEBUG mode off

Any solution without edit the original code? Just for debug.

Offline

#8 2020-12-16 08:38:02

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Turn MVC View Caching in DEBUG mode off

to disable cache for the Default view you could try this

TMVCRunWithViews(fMainRunner).SetCache('Default',cacheNone)

if you have other views cached then you have to do the same for those.

What class are you inheriting from anyway for your MVC application?

Offline

#9 2020-12-29 20:48:32

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Re: Turn MVC View Caching in DEBUG mode off

pvn0 wrote:

to disable cache for the Default view you could try this

TMVCRunWithViews(fMainRunner).SetCache('Default',cacheNone)

if you have other views cached then you have to do the same for those.

What class are you inheriting from anyway for your MVC application?

From IMVCApplication.

So I need set SetCache for all view, there is not a way to set cacheNone to all view at same time, right?

Offline

Board footer

Powered by FluxBB