Opened 11 years ago

Closed 11 years ago

#1716 closed defect (fixed)

Tell browsers not to cache AJAX response data

Reported by: Nicklas Nordborg Owned by: everyone
Priority: major Milestone: BASE 3.2
Component: web Version:
Keywords: Cc:


This seems to mostly be a problem with IE which caches the response for a AJAX/JSON request. This may lead to some strange behavior when old data suddenly shows up or new data seems to not exist.

This can for example be seen when creating new protocols.

  • Make sure a project has been created and selected as an active project.
  • Create a new protocol and give it a type. Make sure the 'Add as project default' option is selected
  • Create another protocol and select the same type. The 'Replace existing default' should pick up the first protocol but it doesn't.
  • Close the protocol dialog, and clear the browser cache (in IE, press F12 and then select Cache->Clear browser cache... from the menu)
  • Start to create a new protocol again. This time the default protocol that was created first should show up when the same 'type' is selected.

The above is just an example. I have not investigated much for other problems that may appear due to the caching, but in general we assume that we get fresh data every time we make an AJAX request, so we should really tell the browser not to cache the response. This is not very hard. Just add the code below to each ajax.jsp script:

response.setHeader("Cache-Control", "no-cache, max-age=0");

Change History (1)

comment:1 by Nicklas Nordborg, 11 years ago

Resolution: fixed
Status: newclosed

(In [6109]) Fixes #1716: Tell browsers not to cache AJAX response data

Note: See TracTickets for help on using tickets.