Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DXA does not set cache headers #6

Closed
jhorsman opened this issue Dec 22, 2015 · 4 comments
Closed

DXA does not set cache headers #6

jhorsman opened this issue Dec 22, 2015 · 4 comments
Milestone

Comments

@jhorsman
Copy link
Contributor

DXA JAVA does not set instructions in the cache headers. Result is that Chome and Firefox do cache resources like images, CSS and JavaScript, but IE does not.

The webapp should be more explicit:

  • set cache headers on all responses so that browsers will interpret cache in the way you intend
  • cache design resources for a long time (everything in the versioned /system/v0.75 url)
  • use content-based (Last-modified or ETag) for other resources; the server can work out if those resources changed
  • expicitly not cache pages; since they could change due to server side responsiveness and content queries.

An additional improvement of a different order (bonus points for that) would be for DXA to figure out if a page changed and return a 304 if the page and it's content did not change.

The .NET version seems to explicitly disable all caching: https://github.com/sdl/dxa-web-application-dotnet/blob/master/Sdl.Web.Mvc/Controllers/NoCacheAttribute.cs

@bkoopman
Copy link
Contributor

The NoCacheAttribute.cs just gives us the use of a [NoCache] attribute on the controllers in DXA .NET, it isn't used on any of the core controllers like Page, Region and Entity, only on the AdminController (which is part of the Site Project).

@jhorsman
Copy link
Contributor Author

@bkoopman I see, so the attribute is available but not used. I guess that means that DXA .NET also does not set cache instructions in the response headers.

@ArjanvanRooijen
Copy link

In the CXC demo we (Philippe) added caching for the system files since these are versionized anyway and should be cached clientside. .Net version blocks this in Java version there is no cache instruction so some browers do like @jhorsman mentioned

Sdl.Web.Mvc\Statics\StaticContentModule.cs

if (urlPath.StartsWith("/system/assets/"))
{
    Log.Debug("Setting cache expiration to allow browser caching.");  
    response.Cache.SetExpires(DateTime.UtcNow.AddDays(10));
    response.Cache.SetCacheability(HttpCacheability.Private);
    response.Cache.SetMaxAge(TimeSpan.FromDays(10));
}

@rpannekoek rpannekoek added this to the v1.3 milestone Dec 23, 2015
@rpannekoek
Copy link
Contributor

Fixed in DXA 1.3

rpannekoek pushed a commit that referenced this issue Mar 1, 2016
…ent-bloom to develop

merging history from remote https://bitbucket.org/contentbloom/sdl-dxa-for-java

* commit 'f21bc59c90c435ed705b2153be11c2d255b1d6af': (22 commits)
  changed local config
  Fixed bug with random ordering of regions
  Removed ContentResolver code as it's now handled by other classes
  Removed handleGetPageJSON action from controller - this should no longer be used, as we don't want to leak dd4t json to the client
  Fix problem with cached requests - dd4t also caches failed broker queries (returning a null value on subsequent calls)
  Removed ContentProvider.GetPageContent (it leaks the underlying data)
  Rename EntityModel.PropertyData to XpmPropertyMetadata
  changed PageData, RegionData & EntityData to XpmMetadata
  Added RegionModelSet classes to Page Model
  added logging to file
  Refactored Page, Region and Entity - renamed to PageModel, RegionModel & EntityModel
  Renamed TRI taglib to DXA
  Added default (dummy) implementation of conditionalentityevaluator
  Added ConditionalEntityEvaluator interface
  added tridion references to tridion provider pom
  Renamed richtextprocessor and removed staticcontentprovider class and interface
  merged staticcontentprovider and contentprovider code, and renamed dd4tcontentprovider to defaultcontentprovider
  Added JSTL dependency to pom
  Fixed page title postfix - removed hardcoded space
  Commit of latest DXA source code
  ...
rpannekoek pushed a commit that referenced this issue Aug 28, 2017
rpannekoek pushed a commit that referenced this issue Aug 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants