cancel
Showing results for 
Search instead for 
Did you mean: 

Share WebScripts cache problem

tonyrivet
Champ in-the-making
Champ in-the-making
Hi,

I'm stuck with a very annoying problem caused by Surf WebSripts displaying cached response when going back on a page.

Let's explain the problem with an example : I have a custom action on the document details page that changes some document properties. This action ends refreshing the document metadata and the page components (metadata, actions…) are well refreshed. But if I move to another page and then go back to the document details page, the metadata component is displayed with the old properties. I have to refresh the page to show the new properties again.

I think the document metadata presentation WebScript returns a cached response that was registered on the page first display before I used my action.

- <strong>Is that a normal behaviour ?</strong>
- <strong>How can I deal with this ?</strong>
- <strong>Is there a way to force the presentation WebScript to refresh its response when using the browser go back button ?</strong>

I tried to add the following cache properties to the metadata presentation WebScript but nothing changed (I guess these are reserved for repo WebScripts…) :

  <cache>
    <never>true</never>
    <mustrevalidate>true</mustrevalidate>
  </cache>



Thank you for your help !
5 REPLIES 5

niketapatel
Star Contributor
Star Contributor
Hi Tony, I might not have understood your flow properly, But metadata/properties that you are retrieving that must be your alfresco data webscript, You can control caching from there.

tonyrivet
Champ in-the-making
Champ in-the-making
Hi and thank you for your answer,

As far as I know, the caching problem really comes from the presentation WebScript.
When you use your browser's go back button, it displays a cache version of the presentation WebScripts response. It does not even execute the presentation WebScript JS controlers, and so does not retrieve the data from the repo…

This can also be reproduced with a native Alfresco on a document details page :
- use the "Manage Aspect" actions to add the "Categorizable" aspect
- notice that the "Categories" property has been added to the metadata view form
- navigate to another page (the "Manage permissions" page for example) and go back to the details page
- notice that the "Categories" property is not shown anymore
- refresh the page
- notice that the "Categories" property is displayed again

niketapatel
Star Contributor
Star Contributor
Hi Tony,

Yes, Got it. I followed your steps and I can reproduce it.

To Solve Presentation webscript caching issue, You can try "noCache= + new Date().getTime()" parameter in your presentation script.

I tried this noCache parameter to solve the scenario you gave for document metadata issue after adding/removing aspect and it;s working.

I appended noCache para in Document metadata URL and it always fetch new data NOT cached data.

url: Alfresco.constants.URL_SERVICECONTEXT + "components/form?noCache=" + new Date().getTime(),

Hope it works!

tonyrivet
Champ in-the-making
Champ in-the-making
Hi,

Yes, your solution definitely works for the document metadata case, because the metadata form is loaded dynamically from the document-metadata.js component (it is not registered in the cached page)… and that's a first step, thank you !

But it doesn't work to refresh the main presentation webscripts response, I mean the ones declared as components in the page template-instance definition file. I tried to add the noCache parameter in the component definition but it doesn't work, and it seems quite normal to me : as the whole page is cached, with all its components, I don't think it is possible to force only one component to refresh.

Maybe it is possible to force one specific page to ignore cache ?
The best solution would be to refresh the cached page when I dynamically refresh one of its components, but I don't know if it is possible without refreshing the whole page…?

tonyrivet
Champ in-the-making
Champ in-the-making
Hi,

I allow myself to reboot this topic because this cache issue really bothers me.
I encounter the same problem dealing with user preferences : when I do an action that changes the user preferences, navigate to another page, and use the go back button the page displays with the old user preferences. When I refresh this page, the preferences are well refreshed.

For each screen that need to retrieve some user preferences, these are retrieved from the preference Surf root object (or the Alfresco.constants.USERPREFERENCES, that is the same thing) and loaded in the page. Using the back button loads a cached version of the page including the old version of the preferences…

What I would like to do is simply refresh these preferences when I go back on a page. What is the best way to achieve this ?
- dealing with page cache ?
- load the preferences with an Ajax request on each components that needs it (that is to say more than once in a single page…) ?
- another idea ??

Thank you.