Question about Web Areas and local cache

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about Web Areas and local cache

KirkBrooks
Here's something I haven't noticed before - I'm developing some html/js
files that display in a webarea in a 4D form. For development I'm opening a
separate process which displays a dialog with a webarea and a button on it.
Clicking the button let's me put in a record number, 4D looks up the
record, and puts it into a c-object variable. Then I open the index.html in
the web area, a javascript function gets the c-obj
<http://kb.4d.com/assetid=77177> and through the magic of Handlebars
renders it into the web area.

So here's the odd part - 4D seems to be caching the js files. I noticed
that if I make a change to the .js files, save them and re-load the web
area I can see in the Web Inspector that it's still running the unchanged
file.

And I can't figure out how to force it to clear. In fact I suddenly realize
I don't know how to do the equivalent of Clear Cache in a web area. I tried
opening a new process but that didn't work. I also tried calling


WA SET PAGE CONTENT(*;$webArea;"";"file:///")


​before re-loading but that didn't work either. ​Restart the database works
but seems a bit inelegant. Here's hoping someone has some insight.

--
Kirk Brooks
San Francisco, CA
=======================
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Question about Web Areas and local cache

KirkBrooks
FWIW - if the context menu is enabled the Reload command on that does the
full relaod.

I'd still like to know how to do it via programming.

On Thu, Dec 1, 2016 at 5:38 PM, Kirk Brooks <[hidden email]> wrote:

> Here's something I haven't noticed before - I'm developing some html/js
> files that display in a webarea in a 4D form. For development I'm opening a
> separate process which displays a dialog with a webarea and a button on it.
> Clicking the button let's me put in a record number, 4D looks up the
> record, and puts it into a c-object variable. Then I open the index.html in
> the web area, a javascript function gets the c-obj
> <http://kb.4d.com/assetid=77177> and through the magic of Handlebars
> renders it into the web area.
>
> So here's the odd part - 4D seems to be caching the js files. I noticed
> that if I make a change to the .js files, save them and re-load the web
> area I can see in the Web Inspector that it's still running the unchanged
> file.
>
> And I can't figure out how to force it to clear. In fact I suddenly
> realize I don't know how to do the equivalent of Clear Cache in a web area.
> I tried opening a new process but that didn't work. I also tried calling
>
>
> WA SET PAGE CONTENT(*;$webArea;"";"file:///")
>
>
> ​before re-loading but that didn't work either. ​Restart the database
> works but seems a bit inelegant. Here's hoping someone has some insight.
>
> --
> Kirk Brooks
> San Francisco, CA
> =======================
>



--
Kirk Brooks
San Francisco, CA
=======================
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

RE: Question about Web Areas and local cache

Timothy Penner
Hi Kirk,

> FWIW - if the context menu is enabled the Reload command on that does the full relaod.
> I'd still like to know how to do it via programming.

I haven't tried it but what about using the JavaScript location.reload() or location.reload(forceGet) with WA EVALUATE JAVASCRIPT ?

http://www.w3schools.com/jsref/met_loc_reload.asp 
http://livedoc.4d.com/4Dv16/help/Command/en/page1029.html

-Tim PENNER
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

RE: Question about Web Areas and local cache

Timothy Penner
In reply to this post by KirkBrooks
I just read the original email:

> So here's the odd part - 4D seems to be caching the js files. I noticed that if I make a change to the .js files, save them and re-load the web area I can see in the Web Inspector that it's still running the unchanged file.

A common trick is to add a random query string to the SRC object like this:
http://stackoverflow.com/a/7413243/5971390

Kind Regards,

-Tim
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Question about Web Areas and local cache

KirkBrooks
Hey Tim,
I'll take a look at that one but your first suggestion seems to do what I
want.

For those of you following along at home here's the actual code:

WA EVALUATE JAVASCRIPT (*;$webArea;"location.reload(true)")


The true param forces the reload from the server. Without that it would
reload from the cache.

Thanks Tim.

On Fri, Dec 2, 2016 at 4:03 PM, Timothy Penner <[hidden email]> wrote:

> I just read the original email:
>
> > So here's the odd part - 4D seems to be caching the js files. I noticed
> that if I make a change to the .js files, save them and re-load the web
> area I can see in the Web Inspector that it's still running the unchanged
> file.
>
> A common trick is to add a random query string to the SRC object like this:
> http://stackoverflow.com/a/7413243/5971390
>
> Kind Regards,
>
> -Tim
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************
>



--
Kirk Brooks
San Francisco, CA
=======================
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Question about Web Areas and local cache

KirkBrooks
In reply to this post by Timothy Penner
Tim,
I think the issue here has to do with testing on a server instance. I'm
editing files stored in the Resources folder but the client is accessing
files in the local cache. The reload is performing - but on the files in
the client cache.

I have the "Update Resources folder during session: Always" option set on
the server. Will that apply to things like these files?

Is there any downside to manually grabbing the files from the server and
writing them to the local Resources folder?

On Fri, Dec 2, 2016 at 4:03 PM, Timothy Penner <[hidden email]> wrote:

> I just read the original email:
>
> > So here's the odd part - 4D seems to be caching the js files. I noticed
> that if I make a change to the .js files, save them and re-load the web
> area I can see in the Web Inspector that it's still running the unchanged
> file.
>
> A common trick is to add a random query string to the SRC object like this:
> http://stackoverflow.com/a/7413243/5971390
>
> Kind Regards,
>
> -Tim
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************
>



--
Kirk Brooks
San Francisco, CA
=======================
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

RE: Question about Web Areas and local cache

Timothy Penner
Have you tried using the NOTIFY RESOURCES FOLDER MODIFICATION command:
http://livedoc.4d.com/4Dv16/help/Command/en/page1052.html

The NOTIFY RESOURCES FOLDER MODIFICATION command "forces" 4D Server to send a notification to all the connected 4D machines indicating that the Resources folder of the database has been modified so that they can synchronize their local Resources folder.
This command can be used more particularly to manage the synchronization of the Resources folders of remote machines after this folder has been modified by a stored procedure on the server.

-Tim PENNER
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Question about Web Areas and local cache

KirkBrooks
That's the sort of thing I was looking for. So it looks like the
auto-update action will only happen when the server executes that command.

   - *Always*: The synchronization of the local *Resources *folder is
   automatically carried out during the session whenever notification is sent
   by the server.

Which means I could make a method that executes the NOTIFY RESOURCES FOLDER
MODIFICATION command, make it Execute on Server and have a mechanism for a
Client machine to initiate the process.


On Fri, Dec 2, 2016 at 4:42 PM, Timothy Penner <[hidden email]> wrote:

> Have you tried using the NOTIFY RESOURCES FOLDER MODIFICATION command:
> http://livedoc.4d.com/4Dv16/help/Command/en/page1052.html
>
> The NOTIFY RESOURCES FOLDER MODIFICATION command "forces" 4D Server to
> send a notification to all the connected 4D machines indicating that the
> Resources folder of the database has been modified so that they can
> synchronize their local Resources folder.
> This command can be used more particularly to manage the synchronization
> of the Resources folders of remote machines after this folder has been
> modified by a stored procedure on the server.
>
> -Tim PENNER
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************
>



--
Kirk Brooks
San Francisco, CA
=======================
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************