How do I clear chache in my website?

MiServer is Dyalog's APL-based web development framework

How do I clear chache in my website?

Postby Gantois on Sat Feb 04, 2017 10:08 am

How do I clear cache in my website ?

My problem is:
I have a link to a login page in my home page, as a navigation menu option. After the login had been concluded, when the user return to home page (clicking on logo / banner) and calls the login page again, the system goes to its initial page without make login.

If I close the browser and call the site again, the home page and login page are ignored and the user goes directly to the initial page, bypassing the home page and the login page.

I think it is a cache problem isnt' it?

I had controled this problem using the login as part of home page, but in my case is important to have the login page as another page.

Thanks,
Marco Gantois
Gantois
 
Posts: 69
Joined: Thu Apr 17, 2014 9:44 am

Re: How do I clear chache in my website?

Postby Brian|Dyalog on Mon Feb 06, 2017 12:32 pm

Hi Marco,

The "problem" as you describe it is how browser-based applications work. So, one question might be - what is it about your application that requires that things work differently?

But, if I understand your situation:
  • You have a home page which is the default page that's loaded when the MiSite is loaded.
  • The home page probably checks something in the user's session (in MiServer) to see if he's logged in, and
    • if he's not logged in, redirects him to your login page.
    • if he is logged in, redirects him to your initial page
  • When the user logs in on the login page, you save the fact that he's logged in somewhere in his MiServer session
If this is the case, then the problem has nothing to do with your browser's cache. The session information you have in MiServer needs to be cleared and it's not possible to differentiate between when the user closes his browser or merely navigates to another page. This, by the way, is a common situation that web developers find themselves in and not something particular to MiServer.

Unfortunately, there's no easy solution. If your MiSite uses a single "main" page once the user has logged in, then it's possible to user the document.unload event to detect if the user navigates away from that page, either by closing his browser or going to some other page using something along the lines of:
Code: Select all
:Class index : MiPage
    ∇ Compose;value
      :Access public
      Add _.h3'Reload and Cookie Test'
      :Select value←_Request.GetCookie'testing'
      :Case 'not_closed'
          Add'page was reloaded - carry on with normal processing'
      :Case 'closed'
          Add'page was closed - clean up session and redirect to login'
      :Else
          Add'??? unknown "testing" cookie value : "',value,'"'
      :EndSelect
     
⍝      Add _.Script ScriptFollows
⍝document.cookie="testing=not_closed";
⍝window.onunload = function() {
⍝document.cookie="testing=closed";
⍝};
    ∇
:EndClass

However, if your MiSite uses multiple pages, things are more complicated because we cannot differentiate how you left the page - it could be because you navigated to another page (either within your application or elsewhere) or closed the browser.

I hope this helps!
/Brian
User avatar
Brian|Dyalog
 
Posts: 71
Joined: Thu Nov 26, 2009 4:02 pm
Location: West Henrietta, NY

Re: How do I clear chache in my website?

Postby Gantois on Wed Feb 08, 2017 9:32 am

Hi Brian,
Thank you,
Marco
Gantois
 
Posts: 69
Joined: Thu Apr 17, 2014 9:44 am


Return to MiServer

Who is online

Users browsing this forum: No registered users and 1 guest