You are not logged in.
Pages: 1
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
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
Hi,
did you have a look at TMVCRunWithViews.SetCache? Looks like a good starting point for further investigation...
Cheers, oz.
Offline
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
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
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
Any solution without edit the original code? Just for debug.
Offline
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
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
Pages: 1