Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
d1933183
Commit
d1933183
authored
Feb 19, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ETag caching not being used for AJAX requests
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
b0097199
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
7 deletions
+29
-7
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+16
-7
changelogs/unreleased/57905-etag-caching-probably-broken-since-11-5-0.yml
...eased/57905-etag-caching-probably-broken-since-11-5-0.yml
+5
-0
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+8
-0
No files found.
app/controllers/application_controller.rb
View file @
d1933183
...
...
@@ -43,7 +43,10 @@ class ApplicationController < ActionController::Base
:git_import_enabled?
,
:gitlab_project_import_enabled?
,
:manifest_import_enabled?
# Adds `no-store` to the DEFAULT_CACHE_CONTROL, to prevent security
# concerns due to caching private data.
DEFAULT_GITLAB_CACHE_CONTROL
=
"
#{
ActionDispatch
::
Http
::
Cache
::
Response
::
DEFAULT_CACHE_CONTROL
}
, no-store"
.
freeze
DEFAULT_GITLAB_CONTROL_NO_CACHE
=
"
#{
DEFAULT_GITLAB_CACHE_CONTROL
}
, no-cache"
.
freeze
rescue_from
Encoding
::
CompatibilityError
do
|
exception
|
log_exception
(
exception
)
...
...
@@ -235,9 +238,9 @@ class ApplicationController < ActionController::Base
end
def
no_cache_headers
response
.
headers
[
"Cache-Control"
]
=
"no-cache, no-store, max-age=0, must-revalidate"
response
.
headers
[
"Pragma"
]
=
"no-cache"
response
.
headers
[
"Expires"
]
=
"Fri, 01 Jan 1990 00:00:00 GMT"
headers
[
'Cache-Control'
]
=
DEFAULT_GITLAB_CONTROL_NO_CACHE
headers
[
'Pragma'
]
=
'no-cache'
# HTTP 1.0 compatibility
headers
[
'Expires'
]
=
'Fri, 01 Jan 1990 00:00:00 GMT'
end
def
default_headers
...
...
@@ -247,10 +250,16 @@ class ApplicationController < ActionController::Base
headers
[
'X-Content-Type-Options'
]
=
'nosniff'
if
current_user
# Adds `no-store` to the DEFAULT_CACHE_CONTROL, to prevent security
# concerns due to caching private data.
headers
[
'Cache-Control'
]
=
DEFAULT_GITLAB_CACHE_CONTROL
headers
[
"Pragma"
]
=
"no-cache"
# HTTP 1.0 compatibility
headers
[
'Cache-Control'
]
=
default_cache_control
headers
[
'Pragma'
]
=
'no-cache'
# HTTP 1.0 compatibility
end
end
def
default_cache_control
if
request
.
xhr?
ActionDispatch
::
Http
::
Cache
::
Response
::
DEFAULT_CACHE_CONTROL
else
DEFAULT_GITLAB_CACHE_CONTROL
end
end
...
...
changelogs/unreleased/57905-etag-caching-probably-broken-since-11-5-0.yml
0 → 100644
View file @
d1933183
---
title
:
Fix ETag caching not being used for AJAX requests
merge_request
:
25400
author
:
type
:
fixed
spec/controllers/application_controller_spec.rb
View file @
d1933183
...
...
@@ -665,6 +665,14 @@ describe ApplicationController do
expect
(
response
.
headers
[
'Cache-Control'
]).
to
eq
'max-age=0, private, must-revalidate, no-store'
end
it
'does not set the "no-store" header for XHR requests'
do
sign_in
(
user
)
get
:index
,
xhr:
true
expect
(
response
.
headers
[
'Cache-Control'
]).
to
eq
'max-age=0, private, must-revalidate'
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment