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
f7ac5384
Commit
f7ac5384
authored
Jul 26, 2018
by
Tim Zallmann
Committed by
Clement Ho
Jul 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DNS Prefetching + Preconnect of assets_host (CDN Domain)
parent
2fbafe1a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
0 deletions
+43
-0
app/views/layouts/_head.html.haml
app/views/layouts/_head.html.haml
+5
-0
changelogs/unreleased/49107-prefetching-of-assets-and-cdn-domain.yml
...unreleased/49107-prefetching-of-assets-and-cdn-domain.yml
+5
-0
spec/views/layouts/_head.html.haml_spec.rb
spec/views/layouts/_head.html.haml_spec.rb
+33
-0
No files found.
app/views/layouts/_head.html.haml
View file @
f7ac5384
...
...
@@ -3,6 +3,11 @@
-
site_name
=
"GitLab"
%head
{
prefix:
"og: http://ogp.me/ns#"
}
%meta
{
charset:
"utf-8"
}
-
if
Feature
.
enabled?
(
'asset_host_prefetch'
)
&&
ActionController
::
Base
.
asset_host
%link
{
rel:
'dns-prefetch'
,
href:
ActionController
::
Base
.
asset_host
}
%link
{
rel:
'preconnnect'
,
href:
ActionController
::
Base
.
asset_host
,
crossorigin:
''
}
%meta
{
'http-equiv'
=>
'X-UA-Compatible'
,
content:
'IE=edge'
}
-# Open Graph - http://ogp.me/
...
...
changelogs/unreleased/49107-prefetching-of-assets-and-cdn-domain.yml
0 → 100644
View file @
f7ac5384
---
title
:
DNS prefetching if asset_host for CDN hosting is set
merge_request
:
20781
author
:
type
:
performance
spec/views/layouts/_head.html.haml_spec.rb
View file @
f7ac5384
...
...
@@ -29,6 +29,39 @@ describe 'layouts/_head' do
expect
(
rendered
).
to
match
(
%{content="foo" http-equiv="refresh"}
)
end
context
'when an asset_host is set and feature is activated in the config it will'
do
let
(
:asset_host
)
{
'http://assets'
}
before
do
stub_feature_flags
(
asset_host_prefetch:
true
)
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
asset_host
)
end
it
'add a link dns-prefetch tag'
do
render
expect
(
rendered
).
to
match
(
'<link href="http://assets" rel="dns-prefetch">'
)
end
it
'add a link preconnect tag'
do
render
expect
(
rendered
).
to
match
(
'<link crossorigin="" href="http://assets" rel="preconnnect">'
)
end
end
context
'when an asset_host is set and feature is not activated in the config it will'
do
let
(
:asset_host
)
{
'http://assets'
}
before
do
stub_feature_flags
(
asset_host_prefetch:
false
)
allow
(
ActionController
::
Base
).
to
receive
(
:asset_host
).
and_return
(
asset_host
)
end
it
'not add a link dns-prefetch tag'
do
render
expect
(
rendered
).
not_to
match
(
'<link href="http://assets" rel="dns-prefetch">'
)
end
end
def
stub_helper_with_safe_string
(
method
)
allow_any_instance_of
(
PageLayoutHelper
).
to
receive
(
method
)
.
and_return
(
%q{foo" http-equiv="refresh}
.
html_safe
)
...
...
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