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

allow caching avatars for 7 days, allow overwriting default headers, remove IE8 hacks #26589

Closed
wants to merge 1 commit into from

Conversation

butonic
Copy link
Member

@butonic butonic commented Nov 9, 2016

Description

  • allow caching avatars for 7 days by sending a Cache-Control: max-age=604800 header. Will change for the user immedeately after changing his avatar. Can still be refreshed by pressing F5
  • allow overwriting Cache-Control and Content-Type
  • remove IE8 hacks. OC no longer supports it.

Related Issue

#26585

Motivation and Context

Performance, technical debt

How Has This Been Tested?

Firefox and Edge work correctly, Chromium works as expected via http but not via https. I expect that to be a bug in chromium.

note that you might want to set session.cache_limiter = to an empty value in your php.ini to prevent PHP from sending deprecated Pragma: no-cache headers that may interfere with IE (Firefox seems to ignore them)

Screenshots (if appropriate):

unbenannt

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Techncal Debt

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@mention-bot
Copy link

@butonic, thanks for your PR! By analyzing the history of the files in this pull request, we identified @PVince81, @rullzer and @LukasReschke to be potential reviewers.

@butonic butonic force-pushed the avatarcontroller-caching-and-cleanup branch from 5745101 to 264fcf5 Compare November 9, 2016 15:22
@butonic butonic changed the title allow caching avatars for 7 days, use JSONResponse, remove IE8 hacks allow caching avatars for 7 days, allow overwriting default headers, remove IE8 hacks Nov 9, 2016
@butonic
Copy link
Member Author

butonic commented Nov 9, 2016

maybe @felixheidecke has opinion ho long to cache the avatar?

@@ -120,22 +120,21 @@ public function getAvatar($userId, $size) {
['Content-Type' => $avatar->getMimeType()]);
$resp->setETag($avatar->getEtag());
} catch (NotFoundException $e) {
$user = $this->userManager->get($userId);
$resp = new DataResponse([
$user = $this->userManager->get($userId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent?

@@ -134,8 +134,7 @@ public function getAvatar($userId, $size) {
]);
}

$resp->addHeader('Pragma', 'public');
$resp->cacheFor(0);
$resp->cacheFor(604800); // allow caching for a week
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we go with 1 or 2 hours here? 7 days seems too long for me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider the use case. How often do I change my Avatar. Every hour? Every day? Everey Week? Probably never again!

As far as I'm concerned a week is just fine.

@DeepDiver1975
Copy link
Member

During my local testing the request still hits the server. Is this intended?

@butonic
Copy link
Member Author

butonic commented Nov 23, 2016

@DeepDiver1975 The initial request, yes. Also, don't use F5 but just hit enter in the location bar. @PhilippSchaffrath and I also came up with a patch for disabling js triggered requests to preview.png. PR pending.

@phisch
Copy link
Contributor

phisch commented Nov 25, 2016

@DeepDiver1975 can you make sure that you don't hit F5 during your test, this would re-load the avatar no matter what the header is. (like @butonic said, click in the address-bar and hit return)

The patch mentioned by @butonic is not really related to this issue.

@PVince81
Copy link
Contributor

How to move forward ? Maybe 1 day is better.

My worry is mostly about invalidating. If someone changed their avatar, maybe it's fine if other users still see the old avatar for a day or so. But if the user who changed their avatar still sees the old avatar for a day, they'll think there's a bug and that the change didn't work.

@PVince81 PVince81 modified the milestones: 10.0.1, 10.0 Apr 26, 2017
@PVince81
Copy link
Contributor

finish or close ?

@PVince81 PVince81 modified the milestones: triage, 10.0.1 May 19, 2017
@PVince81
Copy link
Contributor

PVince81 commented Jul 4, 2017

PR too old, there doesn't seem to be any interest in finishing it. Closing

@PVince81 PVince81 closed this Jul 4, 2017
@DeepDiver1975 DeepDiver1975 deleted the avatarcontroller-caching-and-cleanup branch August 11, 2017 22:54
@felixboehm felixboehm removed this from the triage milestone Apr 10, 2018
@lock
Copy link

lock bot commented Jul 31, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants