Π ΡΡΠΎΠΌ Π·Π°Π΄Π°Π½ΠΈΠΈ Π½Π΅ΠΌΠ½ΠΎΠ³ΠΎ ΠΏΠΎΠΏΡΠ°ΠΊΡΠΈΠΊΡΠ΅ΠΌΡΡ Ρ HTTP/2
Π² Rails
.
ΠΠΎΠ»ΡΠ·Π°:
- Π½Π°ΡΡΠΈΡΡΡΡ Π½Π°ΡΡΡΠ°ΠΈΠ²Π°ΡΡ
HTTPS
Π΄Π»Ρ Π»ΠΎΠΊΠ°Π»ΡΠ½ΠΎΠ³ΠΎRails
-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ - Π½Π°ΡΡΠΈΡΡΡΡ Π½Π°ΡΡΡΠ°ΠΈΠ²Π°ΡΡ
HTTP/2
reverse proxy
Ρ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΊΠΎΠΉserver-push
- Π½Π°ΡΡΠΈΡΡΡΡ Π΄Π΅Π»Π°ΡΡ
server-push
, ΡΡΠ°Π²Π½ΠΈΡΡ Π΅Π³ΠΎ Ρinlining
Π Π°Π±ΠΎΡΠ°ΡΡ Π±ΡΠ΄Π΅ΠΌ Π½Π° ΠΏΡΠΈΠΌΠ΅ΡΠ΅ ΠΏΡΠΎΠ΅ΠΊΡΠ° dev.to
, ΠΊΠ°ΠΊ ΠΈ Π² ΠΏΡΠΎΡΠ»ΠΎΠΌ Π·Π°Π΄Π°Π½ΠΈΠΈ.
Π Π΅ΡΡΡΡΡ:
- https://github.com/FiloSottile/mkcert - ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½Ρ Π΄Π»Ρ Π½Π°ΡΡΡΠΎΠΉΠΊΠΈ Π»ΠΎΠΊΠ°Π»ΡΠ½ΡΡ ΡΠ΅ΡΡΠΈΡΠΈΠΊΠ°ΡΠΎΠ² ΠΎΠ΄Π½ΠΎΠΉ ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ
- https://www.nginx.com/blog/nginx-1-13-9-http2-server-push/ - Π½Π°ΡΡΡΠΎΠΉΠΊΠ°
http2-server-push
Π²NGinx
. - https://github.com/surma/http2-push-detect - ΡΡΠΈΠ»ΠΈΡΠ° Π΄Π»Ρ ΠΏΡΠΎΠ²Π΅ΡΠΊΠΈ
server-push
- http://railscasts.com/episodes/357-adding-ssl?view=asciicast - ΡΡΠ°ΡΡΠΉ, Π½ΠΎ ΠΎΡΠ΅Π½Ρ ΠΏΠΎΠ½ΡΡΠ½ΡΠΉ
RailsCast
ΠΏΡΠΎssl
ΠΠΎΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°ΡΡ Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ mkcert
Π£ΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ΠΈΠ»ΠΈ ΠΎΠ±Π½ΠΎΠ²ΠΈΡΡ NGinx
.
ΠΠΎΠ½ΡΠΈΠ³ΡΡΠΈΡΡΠ΅ΠΌ NGinx
ΡΠ°ΠΊ, ΡΡΠΎΠ±Ρ ΠΎΠ½ ΠΏΡΠΈΠ½ΠΈΠΌΠ°Π» https
-Π·Π°ΠΏΡΠΎΡΡ https://localhost
ΠΈ Ρ
ΠΎΠ΄ΠΈΠ» Π² upstream
Π½Π° http://localhost:3000
.
server {
listen 443 ssl;
server_name localhost;
ssl_certificate /path/to/localhost.pem;
ssl_certificate_key /path/to/localhost-key.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3-SHA:!RC4:!aNULL:!eNULL:!MD5:!EXPORT:!EXP:!LOW:!SEED:!CAMELLIA:!IDEA:!PSK:!SRP:!SSLv:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_prefer_server_ciphers on;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
proxy_pass http://127.0.0.1:3000;
}
}
ΠΠ° ΡΡΠΎΠΌ ΡΠ°Π³Π΅ Π±ΡΠ°ΡΠ·Π΅Ρ Π΄ΠΎΠ»ΠΆΠ΅Π½ ΡΡΠΏΠ΅ΡΠ½ΠΎ ΠΎΡΠΊΡΡΠ²Π°ΡΡ https://localhost
ΠΠΎΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΠΊΠΎΠ½ΡΠΈΠ³ NGinx
ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΊΠΎΠΉ HTTP/2
ΠΈ server-push
server {
listen 443 http2 ssl;
#...
location /{
http2_push_preload on;
#...
}
}
ΠΠ° Π³Π»Π°Π²Π½ΠΎΠΌ ΡΠΊΡΠ°Π½Π΅ Π² ΠΌΠΎΠ±ΠΈΠ»ΡΠ½ΠΎΠΌ Π²ΠΈΠ΄Π΅ dev.to
Π΅ΡΡΡ ΡΡΠ΄ ΠΊΠ°ΡΡΠΈΠ½ΠΎΠΊ:
connect.svg
bell.svg
menu.svg
stack.svg
lightning.svg
ΠΠ°ΡΡΠΈΠ½ΠΊΠΈ ΠΈΠ· ΠΌΠ΅Π½Ρ: connect.svg
, bell.svg
, menu.svg
β Π·Π°ΠΈΠ½Π»Π°ΠΉΠ½Π΅Π½Ρ.
ΠΠ°ΡΡΠΈΠ½ΠΊΠΈ stack.svg
ΠΈ lightning.svg
β Π½Π΅Ρ.
ΠΠΎΠΏΡΠΎΠ±ΡΠΉΡΠ΅ ΠΏΠ΅ΡΠ΅Π·Π°Π³ΡΡΠΆΠ°ΡΡ ΡΡΡ ΡΡΡΠ°Π½ΠΈΡΡ Ρ ΡΠΌΡΠ»ΡΡΠΈΠ΅ΠΉ ΠΌΠ΅Π΄Π»Π΅Π½Π½ΠΎΠ³ΠΎ ΡΠΎΠ΅Π΄ΠΈΠ½Π΅Π½ΠΈΡ ΠΈ ΠΏΠΎΡΠΌΠΎΡΡΠ΅ΡΡ ΠΊΠ°ΠΊ ΡΠ΅Π½Π΄Π΅ΡΡΡΡΡ ΡΡΠΈ ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΠΏΡΠΈ ΠΏΠ΅ΡΠ΅Π·Π°Π³ΡΡΠ·ΠΊΠ΅.
ΠΠ°Π»ΡΡΠ΅, Π΄Π°Π²Π°ΠΉΡΠ΅ ΠΏΠΎΠΏΡΠΎΠ±ΡΠ΅ΠΌ Π΄Π²ΠΈΠ½ΡΡΡΡΡ Π² ΡΡΠΎΡΠΎΠ½Ρ ΠΏΠΎΠ΄Ρ
ΠΎΠ΄Π° HTTP/2
ΠΈ Π½Π΅ Π±ΡΠ΄Π΅ΠΌ ΠΈΠ½Π»Π°ΠΉΠ½ΠΈΡΡ svg
, Π° ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠΈΠΌ ΠΈΡ
ΠΊΠ°ΠΊ ΠΎΠ±ΡΡΠ½ΡΠ΅ ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ.
ΠΠ°ΠΏΡΠΈΠΌΠ΅Ρ, image_tag("bell.svg", size: "100% * 100%")
Π’Π΅ΠΏΠ΅ΡΡ Π΄Π°Π²Π°ΠΉΡΠ΅ Π΄ΠΎΠ±Π°Π²ΠΈΠΌ server-push
!
ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π½Π°ΠΌ Π½ΡΠΆΠ½ΠΎ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΡΠ΅ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠΈ:
# stories_controller.rb
def index
push_headers = [
"<#{view_context.asset_path('bell.svg')}>; rel=preload; as=image",
"<#{view_context.asset_path('menu.svg')}>; rel=preload; as=image",
"<#{view_context.asset_path('connect.svg')}>; rel=preload; as=image",
"<#{view_context.asset_path('stack.svg')}>; rel=preload; as=image",
"<#{view_context.asset_path('lightning.svg')}>; rel=preload; as=image",
]
response.headers['Link'] = push_headers.join(', ')
# ...
end
ΠΠ° ΡΡΠΎΠΌ ΡΠ°Π³Π΅ Π½ΡΠΆΠ½ΠΎ ΡΠ±Π΅Π΄ΠΈΡΡΡΡ, ΡΡΠΎ server-push
ΡΠ°Π±ΠΎΡΠ°Π΅Ρ.
Π Chrome
DevTools
Π² ΠΏΠ°Π½Π΅Π»ΠΈ Network
Π²Ρ Π΄ΠΎΠ»ΠΆΠ½Ρ ΡΠ²ΠΈΠ΄Π΅ΡΡ, ΡΡΠΎ Π·Π°ΠΏΡΠΎΡΡ ΠΊ ΡΡΠΈΠΌ ΠΊΠ°ΡΡΠΈΠ½ΠΊΠ°ΠΌ Π΄Π΅Π»Π°ΡΡΡΡ ΠΏΠΎ ΠΏΡΠΎΡΠΎΠΊΠΎΠ»Ρ h2
, Π° Initiator
= Push/Other
ΠΡΡ ΠΎΠ΄ΠΈΠ½ ΡΠΏΠΎΡΠΎΠ± ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ ΡΠ°Π±ΠΎΡΡ server-push
- ΡΡΠΈΠ»ΠΈΡΠ° http2-push-detect
http2-push-detect https://localhost
Receiving pushed resource: /assets/bell.svg
Receiving pushed resource: /assets/menu.svg
Receiving pushed resource: /assets/connect.svg
Receiving pushed resource: /assets/stack.svg
Receiving pushed resource: /assets/lightning.svg
Π’Π΅ΠΏΠ΅ΡΡ ΠΏΠΎΡΠΊΡΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½ΡΠΈΡΡΠΉΡΠ΅, ΠΏΠΎΠΏΡΠΎΠ±ΡΠΉΡΠ΅ Π²ΠΊΠ»ΡΡΠ°ΡΡ ΠΈ Π²ΡΠΊΠ»ΡΡΠ°ΡΡ server-push
Π΄Π»Ρ ΡΠ΅Ρ
ΠΈΠ»ΠΈ ΠΈΠ½ΡΡ
ΠΊΠ°ΡΡΠΈΠ½ΠΎΠΊ ΠΈ ΠΎΡΠ΅Π½ΠΈΡΠ΅, ΠΊΠ°ΠΊ ΡΡΠΎ ΡΠΊΠ°Π·ΡΠ²Π°Π΅ΡΡΡ Π½Π° ΠΈΡ
ΡΠ΅Π½Π΄Π΅ΡΠΈΠ½Π³Π΅.
Π‘ΡΠ°Π²Π½ΠΈΠΌ Π²Π°ΡΠΈΠ°Π½Ρ Ρ server-push
ΠΈ Ρ ΠΎΠ±ΡΡΠ½ΡΠΌΠΈ ΠΊΠ°ΡΡΠΈΠ½ΠΊΠ°ΠΌΠΈ Π±Π΅Π· ΠΈΠ½Π»Π°ΠΉΠ½ΠΈΠ½Π³Π° ΠΈ Π±Π΅Π· ΠΏΡΡΠ°.
ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌΡΡ sitespeed.io
(ΠΏΠΎΠ΄ΡΠΎΠ±Π½ΠΎ ΡΠ°ΡΡΠΊΠ°ΠΆΡ ΠΎΠ± ΡΡΠΎΠΌ ΠΌΠΎΡΠ½ΠΎΠΌ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠ΅ Π² Π»Π΅ΠΊΡΠΈΠΈ β6)
ΠΡΠΏΠΎΠ»Π½ΠΈΡΠ΅ Π°Π½Π°Π»ΠΈΠ· Π²Π΅ΡΡΠΈΠΈ Π±Π΅Π· server-push
ΠΈ Π±Π΅Π· inline
:
docker run --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io --mobile -n 5 --preUrl https://host.docker.internal/ https://host.docker.internal/
# --mobile - ΠΌΠΎΠ±ΠΈΠ»ΡΠ½ΡΠΉ Π²ΠΈΠ΄
# -n 5 - 5 ΠΏΠΎΠ²ΡΠΎΡΠΎΠ²
# --preUrl https://host.docker.internal/ - ΡΡΠ», ΠΏΠ΅ΡΠ²ΠΎΠ³ΠΎ Π·Π°Ρ
ΠΎΠ΄Π°
# https://host.docker.internal/ - ΡΡΠ» ΠΏΠΎΠ²ΡΠΎΡΠΎΠ½ΠΎΠ³ΠΎ Π·Π°Ρ
ΠΎΠ΄Π°, ΠΊΠΎΡΠΎΡΡΠΉ ΠΈ Π°Π½Π°Π»ΠΈΠ·ΠΈΡΡΠ΅ΠΌ
# Π° Π²ΠΎΠΎΠ±ΡΠ΅ https://host.docker.internal/ - ΡΡΠΎ https://localhost, Π½Π° ΠΊΠΎΡΠΎΡΠΎΠΌ ΡΡΠΎΠΈΡ Π²Π°Ρ Π»ΠΎΠΊΠ°Π»ΡΠ½ΡΠΉ `HTTP/2-proxy` Ρ ΡΠΎΡΠΊΠΈ Π·ΡΠ΅Π½ΠΈΡ `docker`.
ΠΡΠΊΡΠΎΠΉΡΠ΅ ΡΠ³Π΅Π½Π΅ΡΠΈΡΠΎΠ²Π°Π½Π½ΡΠΉ ΠΎΡΡΡΡ sitespeed.io
, Π·Π°ΠΉΠ΄ΠΈΡΠ΅ Π½Π° Π²ΠΊΠ»Π°Π΄ΠΊΡ Pages
, ΡΠ°ΠΌ ΠΏΡΠΎΠ²Π°Π»ΠΈΡΠ΅ΡΡ Π² ΠΎΡΡΡΡ ΠΏΠΎ Π΅Π΄ΠΈΠ½ΡΡΠ²Π΅Π½Π½ΠΎΠΉ ΡΡΡΠ°Π½ΠΈΡΠ΅, ΠΈ Π²Π½ΠΈΠ·Ρ Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΡΠΉΡΠ΅ΡΡ ΠΊΠ½ΠΎΠΏΠΊΠΎΠΉ DOWNLOAD HAR
- ΡΠΎΡ
ΡΠ°Π½ΠΈΡΠ΅ HAR
-ΡΠ°ΠΉΠ», Π·Π°ΠΊΠΎΠΌΠΈΡΡΡΡΠ΅ Π΅Π³ΠΎ.
Π‘Π΄Π΅Π»Π°ΠΉΡΠ΅ ΡΠΎ ΠΆΠ΅, ΡΡΠΎ Π² ΠΏΡΠ½ΠΊΡΠ΅ 5.1
, Π½ΠΎ Ρ Π²Π΅ΡΡΠΈΠ΅ΠΉ, Π³Π΄Π΅ ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°ΡΡΡΡ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠΈ server-push
. Π‘ΠΎΡ
ΡΠ°Π½ΠΈΡΠ΅ HAR
-ΡΠ°ΠΉΠ», Π·Π°ΠΊΠΎΠΌΠΈΡΡΡΡΠ΅ Π΅Π³ΠΎ.
Π‘ΡΠ°Π²Π½ΠΈΡΠ΅ Π΄Π²Π° ΠΏΠΎΠ»ΡΡΠ΅Π½Π½ΡΡ
HAR
-ΡΠ°ΠΉΠ»Π° Ρ ΠΏΠΎΠΌΠΎΡΡΡ https://compare.sitespeed.io/
ΠΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΠΎ Π΄ΠΎΠ±Π°Π²ΡΡΠ΅ ΡΡΡΠ»ΠΊΡ Π½Π° ΡΡΠ°Π²Π½Π΅Π½ΠΈΠ΅ Π² ΠΎΠΏΠΈΡΠ°Π½ΠΈΠ΅ PR
ΠΡ Π΄ΠΎΠ»ΠΆΠ½Ρ ΡΠ²ΠΈΠ΄Π΅ΡΡ Π½Π° Waterfall
, ΡΡΠΎ server-push
ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΠΎΡΠΏΡΠ°Π²Π»ΡΡΡΡΡ Π² ΡΠ°ΠΌΡΡ ΠΏΠ΅ΡΠ²ΡΡ ΠΎΡΠ΅ΡΠ΅Π΄Ρ.
ΠΠ° filmstrip
ΠΈ video
ΡΠ°ΠΊΠΆΠ΅ ΠΌΠΎΠΆΠ½ΠΎ ΡΠ²ΠΈΠ΄Π΅ΡΡ, ΡΡΠΎ server-push
ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ Π΄Π΅ΠΉΡΡΠ²ΠΈΡΠ΅Π»ΡΠ½ΠΎ ΠΏΠΎΡΠ²Π»ΡΡΡΡΡ Π·Π°ΠΌΠ΅ΡΠ½ΠΎ ΡΠ°Π½ΡΡΠ΅.
ΠΡΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°ΡΡ PR
Π² ΡΡΠΎΡ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ Ρ Π²Π°ΡΠΈΠΌΠΈ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΡΠΌΠΈ ΠΊΠΎΠ΄Π° dev.to
Π΄Π»Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ server-push
, ΠΊΠΎΠ½ΡΠΈΠ³ΠΎΠΌ NGinx
, ΡΡΡΠ»ΠΊΠΎΠΉ Π½Π° ΡΡΠ°Π²Π½Π΅Π½ΠΈΠ΅ HAR
-ΡΠ°ΠΉΠ»ΠΎΠ² ΠΈ ΠΎΠΏΠΈΡΠ°Π½ΠΈΠ΅ΠΌ.
- Π Π΅Π°Π»ΠΈΠ·Π°ΡΠΈΡ
server-push
Π΄Π»Ρ ΡΠΊΠ°Π·Π°Π½Π½ΡΡ Π² Π·Π°Π΄Π°Π½ΠΈΠΈ ΠΊΠ°ΡΡΠΈΠ½ΠΎΠΊ - ΠΠΎΠ½ΡΠΈΠ³
NGinx
- Π‘ΡΡΠ»ΠΊΠ° Π½Π° ΡΡΠ°Π²Π½Π΅Π½ΠΈΠ΅
HAR
-ΡΠ°ΠΉΠ»ΠΎΠ² Ρserver-push
ΠΈ Π±Π΅Π· - ΠΠΎΠ½ΡΡ 1 ΠΏΡΠΎ
dev.to
- ΠΠΎΠ½ΡΡ 2 ΠΏΡΠΎ
Falcon
Π’Π΅ΠΏΠ΅ΡΡ, ΠΊΠΎΠ³Π΄Π° Ρ Π²Π°Ρ ΡΡΠΎΡΠΌΠΈΡΠΎΠ²Π°Π»Π°ΡΡ ΠΈΠ½ΡΡΠΈΡΠΈΡ ΠΏΠΎ ΡΠ°Π±ΠΎΡΠ΅ Ρ HTTP/2
ΠΈ server-push
, ΠΏΠΎΡΡΡΠΎΠΉΡΠ΅ ΠΈ ΠΏΡΠΎΠ°Π½Π°Π»ΠΈΠ·ΠΈΡΡΠΉΡΠ΅ ΠΎΡΡΡΡ WebPageTest
Π΄Π»Ρ ΡΠ°ΠΉΡΠ° dev.to
(Π½Π° ΠΏΡΠΎΠ΄Π΅).
ΠΠΈΠ΄ΠΈΡΠ΅ Π»ΠΈ Π²Ρ ΠΊΠ°ΠΊΠΈΠ΅-ΡΠΎ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΠΈ HTTP/2
Π΄Π»Ρ ΠΎΠΏΡΠΈΠΌΠΈΠ·Π°ΡΠΈΠΈ dev.to
, ΠΈΡΡ
ΠΎΠ΄Ρ ΠΈΠ· ΠΎΡΡΡΡΠΎΠ² WPT
?
ΠΠΈΠ΄ΠΈΡΠ΅ Π»ΠΈ ΠΊΠ°ΠΊΠΈΠ΅-ΡΠΎ ΡΠΎΡΠΊΠΈ ΡΠΎΡΡΠ° Π² ΠΎΡΡΠ°Π»ΡΠ½ΠΎΠΌ?
Π‘Π΅ΡΠ²Π΅Ρ Falcon
https://github.com/socketry/falcon ΡΡΠ²Π΅ΡΠΆΠ΄Π°Π΅Ρ, ΡΡΠΎ ΠΌΠΎΠΆΠ΅Ρ ΡΠ΅ΡΠ²ΠΈΡΡ Rails
-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΈ ΠΈΠ· ΠΊΠΎΡΠΎΠ±ΠΊΠΈ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ HTTP/2
.
ΠΠΎΠΏΡΠΎΠ±ΡΠΉΡΠ΅ Π½Π°ΡΡΡΠΎΠΈΡΡ ΡΠ°Π±ΠΎΡΡ dev.to
Ρ server-push
Π΄Π»Ρ Falcon
.
Π‘Π΄Π΅Π»Π°ΠΉΡΠ΅ ΡΡΠ°Π²Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠΉ Π±Π΅Π½ΡΠΌΠ°ΡΠΊ puma
ΠΈ falcon
Π½Π° ΠΏΡΠΈΠΌΠ΅ΡΠ΅ Π³Π»Π°Π²Π½ΠΎΠΉ ΡΡΡΠ°Π½ΠΈΡΡ dev.to
.
Welcome to the dev.to codebase. We are so excited to have you. With your help, we can build out DEV to be more stable and better serve our community.
dev.to (or just DEV) is a platform where software developers write articles, take part in discussions, and build their professional profiles. We value supportive and constructive dialogue in the pursuit of great code and career growth for all members. The ecosystem spans from beginner to advanced developers, and all are welcome to find their place within our community. β€οΈ
We encourage you to contribute to dev.to! Please check out the Contributing to dev.to guide for guidelines about how to proceed.
We expect contributors to abide by our underlying code of conduct. All conversations and discussions on GitHub (issues, pull requests) and across dev.to must be respectful and harassment-free.
All issues labeled with approved
are up for grabs. For clarification on how we label issues, check out their definitions here.
When in doubt, ask a core team member! You can mention us in any issues or ask on the DEV Contributor thread. Any issue with the good first issue
tag is typically a good place to start for anyone new to the project. For newer developers, try 'entry-level' issues.
Refactoring code, e.g. improving the code without modifying the behavior is an area that can probably be done based on intuition and may not require much communication to be merged.
Fixing bugs may also not require a lot of communication, but the more the better. Please surround bug fixes with ample tests. Bugs are magnets for other bugs. Write tests near bugs!
Building features is the area which will require the most communication and/or negotiation. Every feature is subjective and open for debate. The product roadmap should be a good guide to follow. As always, when in doubt, ask!
- Fork the project & clone locally. Follow the initial setup here.
- Create a branch, naming it either a feature or bug:
git checkout -b feature/that-new-feature
orbug/fixing-that-bug
- Code and commit your changes. Bonus points if you write a good commit message:
git commit -m 'Add some feature'
- Push to the branch:
git push origin feature/that-new-feature
- Create a pull request for your branch π
Note: be sure to maintain your fork!
Nobody's perfect. Something doesn't work? Or could be done better? Let us know by creating an issue.
PS: a clear and detailed issue gets lots of love, all you have to do is follow the issue template!
Some existing code may be poorly written or untested, so we must have more scrutiny going forward. We test with rspec, let us know if you have any questions about this!
- Try to keep the pull requests small. A pull request should try its very best to address only a single concern.
- Make sure all tests pass and add additional tests for the code you submit. More info here
- Document your reasoning behind the changes. Explain why you wrote the code in the way you did. The code should explain what it does.
- If there's an existing issue related to the pull request, reference to it by adding something like
References/Closes/Fixes/Resolves #305
, where 305 is the issue number. More info here - If you follow the pull request template, you can't go wrong.
Please note: all commits in a pull request will be squashed when merged, but when your PR is approved and passes our CI, it will be live on production!
Whether you are stuck with feature implementation, first-time setup, or you just want to tell us something could be done better, check out our OSS thread or create an issue. You can also mention any core team member in an issue and we'll respond as soon as possible.
π OSS Help/Discussion Thread π
We are all humans trying to work together to improve the community. Always be kind and appreciate the need for tradeoffs. β€οΈ
We run on a Rails backend with mostly vanilla JavaScript on the front end, and some Preact sprinkled in. One of our goals is to move to mostly Preact for our front end.
Additional technologies and services are listed on our docs.
This project follows thoughtbot's Ruby Style Guide, using Rubocop along with Rubocop-Rspec as the code analyzer. If you have Rubocop installed with your text editor of choice, you should be up and running.
For Javascript, we follow Airbnb's JS Style Guide, using ESLint and prettier. If you have ESLint installed with your text editor of choice, you should be up and running.
When commits are made, a git precommit hook runs via husky and lint-staged. ESLint, prettier, and Rubocop will run on your code before it's committed. If there are linting errors that can't be automatically fixed, the commit will not happen. You will need to fix the issue manually then attempt to commit again.
Note: if you've already installed the husky package at least once (used for precommit npm script), you will need to run yarn --force
or npm install --no-cache
. For some reason, the post-install script of husky does not run when the package is pulled from yarn or npm's cache. This is not husky specific, but rather a cached package issue.
This section provides a high-level requirement & quick start guide. For detailed installations, please check out our docs.
- Ruby: we recommend using rbenv to install the Ruby version listed on the badge.
- Yarn: please refer to their installation guide.
- PostgreSQL 9.4 or higher.
- Make sure all the prerequisites are installed.
- Fork dev.to repository, ie. https://github.com/thepracticaldev/dev.to/fork
- Clone your forked repository, ie.
git clone https://github.com/<your-username>/dev.to.git
gem install foreman
- Setup your database
- Create
config/database.yml
by copying from the provided template (i.e.cp config/database.yml.sample config/database.yml
) - Update the
config/database.yml
file if needed.
- Create
- Set up your environment variables/secrets
- Take a look at
Envfile
. This file lists all theENV
variables we use and provides a fake default for any missing keys. You'll need to get your own free Algolia credentials to get your development environment running. - This guide will show you how to get free API keys for additional services that may be required to run certain parts of the app.
- For any key that you wish to enter/replace:
- Create
config/application.yml
by copying from the provided template (ie. with bash:cp config/sample_application.yml config/application.yml
). This is a personal file that is ignored in git. - Obtain the development variable and apply the key you wish to enter/replace. ie:
GITHUB_KEY: "SOME_REAL_SECURE_KEY_HERE" GITHUB_SECRET: "ANOTHER_REAL_SECURE_KEY_HERE"
- Create
- If you are missing
ENV
variables on bootup,envied
gem will alert you with messages similar to'error_on_missing_variables!': The following environment variables should be set: A_MISSING_KEY.
. - You do not need "real" keys for basic development. Some features require certain keys, so you may be able to add them as you go.
- Take a look at
- Run
bin/setup
- That's it! Run
bin/startup
to start the application and head tohttp://localhost:3000/
View Full Installation Documentation
Our docker implementation is incomplete and may not work smoothly. Please kindly report any issues and any contribution is welcomed!
- Install
docker
anddocker-compose
git clone [email protected]:thepracticaldev/dev.to.git
- Set environment variables above as described in the "Basic Installation"
- run
docker-compose build
- run
docker-compose run web rails db:setup
- run
docker-compose run web yarn install
- run
docker-compose up
- That's it! Navigate to
localhost:3000
We're mostly a Rails app, with a bit of Webpack sprinkled in. For most cases, simply running bin/rails server
will do. If you're working with Webpack though, you'll need to run the following:
- Run
bin/startup
to start the server, Webpack, and our job runnerdelayed_job
.bin/startup
runsforeman start -f Procfile.dev
under the hood. alias start="bin/startup"
makes this even faster. π- If you're using
pry
for debugging in Rails, note that usingforeman
andpry
together works, but it's not as clean asbin/rails server
.
Here are some singleton commands you may need, usually in a separate instance/tab of your shell.
- Running the job server (if using
bin/rails server
) -- this is mostly for notifications and emails:bin/rails jobs:work
- Clearing jobs (in case you don't want to wait for the backlog of jobs):
bin/rails jobs:clear
Current gotchas: potential environment issues with external services need to be worked out.
We use Spring and it is already included in the project.
- Use the provided bin stubs to automatically start Spring, i.e.
bin/rails server
,bin/rspec spec/models/
,bin/rake db:migrate
. - If Spring isn't picking up on new changes, use
spring stop
. For example, Spring should always be restarted if there's a change in environment key. - Check Spring's status whenever with
spring status
.
Caveat: bin/rspec
is not equipped with Spring because it affects Simplecov's result. Instead use bin/spring rspec
.
Check out our dedicated docs page for more technical documentation.
Our new product roadmap can be found here. Many notes need to be converted to issues but this should provide an overview of features we plan to work on, as well as features we are considering.
Core team members will move issues along the project board as they progress.
- Ideas & Requests: features up for discussion.
- Needs Owners: features in need of an owner.
- Committed: features we're committed to building -- free for contributors to work on, but please communicate with the owner beforehand.
- In Progress (early stage): work has begun on feature.
- In Progress (late stage): feature is near completion.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Please see the LICENSE file in our repository for the full text.
Like many open source projects, we require that contributors provide us with a Contributor License Agreement (CLA). By submitting code to the DEV project, you are granting us a right to use that code under the terms of the CLA.
Our version of the CLA was adapted from the Microsoft Contributor License Agreement, which they generously made available to the public domain under Creative Commons CC0 1.0 Universal.
Any questions, please refer to our license FAQ doc or email [email protected]