From 3e698ae7ffc5c278e4de0c0ab52d9c4f9638dfac Mon Sep 17 00:00:00 2001 From: Taras Pochkun Date: Wed, 6 Jul 2022 21:57:11 +0300 Subject: [PATCH 1/2] The task 5. --- .gitignore | 5 +- .nvmrc | 3 +- .ruby-gemset | 1 + .ruby-version | 2 +- Gemfile | 4 +- Gemfile.lock | 24 +- Readme.md | 7 +- app/controllers/stories_controller.rb | 10 + app/views/layouts/_top_bar.html.erb | 6 +- config/environments/development.rb | 1 + hars/browsertime-0.har | 1 + hars/browsertime-1.har | 1 + hars/browsertime-2.har | 1 + package.json | 1 + yarn.lock | 8103 +++++++++++++++---------- 15 files changed, 4780 insertions(+), 3390 deletions(-) create mode 100644 .ruby-gemset create mode 100644 hars/browsertime-0.har create mode 100644 hars/browsertime-1.har create mode 100644 hars/browsertime-2.har diff --git a/.gitignore b/.gitignore index df2840a..08d6de9 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,7 @@ package-lock.json .idea/ #sitemap -/public/sitemap.xml.gz \ No newline at end of file +/public/sitemap.xml.gz + +crt +sitespeed-result diff --git a/.nvmrc b/.nvmrc index 0312896..bfeac55 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1,2 @@ -lts/dubnium +v14.19.3 + diff --git a/.ruby-gemset b/.ruby-gemset new file mode 100644 index 0000000..ed75999 --- /dev/null +++ b/.ruby-gemset @@ -0,0 +1 @@ +rails-optimization-task5 diff --git a/.ruby-version b/.ruby-version index 6a6a3d8..12d9bd0 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.1 +ruby-2.6.1 diff --git a/Gemfile b/Gemfile index bf57e9a..d5513bc 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ end gem "actionpack-action_caching", "~> 1.2" gem "active_record_union", "~> 1.3" gem "acts-as-taggable-on", "~> 5.0" -gem "acts_as_follower", github: "thepracticaldev/acts_as_follower", branch: "master" +gem "acts_as_follower", github: "forem/acts_as_follower", branch: "master" gem "addressable", "~> 2.5", ">= 2.5.2" gem "administrate", "~> 0.11" gem "ahoy_email", "~> 0.5" @@ -122,7 +122,7 @@ group :development, :test do gem "derailed", "~> 0.1" gem "erb_lint", "~> 0.0", require: false gem "faker", git: "https://github.com/stympy/faker.git", branch: "master" - gem "fix-db-schema-conflicts", github: "thepracticaldev/fix-db-schema-conflicts", branch: "master" + gem "fix-db-schema-conflicts", github: "jakeonrails/fix-db-schema-conflicts", branch: "master" gem "memory_profiler", "~> 0.9" gem "parallel_tests", "~> 2.27" gem "pry-byebug", "~> 3.7" diff --git a/Gemfile.lock b/Gemfile.lock index 331bf9c..574c972 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,26 +1,26 @@ GIT - remote: https://github.com/stympy/faker.git - revision: 9910aa58d92c018abab25d491191576fcc1a7707 + remote: https://github.com/forem/acts_as_follower.git + revision: 06393d3693a1a3d4b390aec4976c8b8f3a81cf01 branch: master specs: - faker (1.9.1) - i18n (>= 0.7) + acts_as_follower (0.2.1) + activerecord (>= 4.0) GIT - remote: https://github.com/thepracticaldev/acts_as_follower.git - revision: 288690cd99bc470eaee493fce5bfa9fe23157692 + remote: https://github.com/jakeonrails/fix-db-schema-conflicts.git + revision: 1e94f518503f1d1addd6ed052454efcbec0b3c6a branch: master specs: - acts_as_follower (0.2.1) - activerecord (>= 4.0) + fix-db-schema-conflicts (3.1.0) + rubocop (>= 0.38.0) GIT - remote: https://github.com/thepracticaldev/fix-db-schema-conflicts.git - revision: 4172392392e1a8d907f7ab673cb5ddd9a4a31940 + remote: https://github.com/stympy/faker.git + revision: 9910aa58d92c018abab25d491191576fcc1a7707 branch: master specs: - fix-db-schema-conflicts (3.0.2) - rubocop (>= 0.38.0) + faker (1.9.1) + i18n (>= 0.7) GEM remote: https://rubygems.org/ diff --git a/Readme.md b/Readme.md index 33dbe77..23ddc13 100644 --- a/Readme.md +++ b/Readme.md @@ -6,9 +6,9 @@ Польза: -- научиться настраивать `HTTPS` для локального `Rails`-приложения -- научиться настраивать `HTTP/2` `reverse proxy` с поддержкой `server-push` -- научиться делать `server-push`, сравнить его с `inlining` +- [+] научиться настраивать `HTTPS` для локального `Rails`-приложения +- [+] научиться настраивать `HTTP/2` `reverse proxy` с поддержкой `server-push` +- [+] научиться делать `server-push`, сравнить его с `inlining` ## ToDo @@ -176,7 +176,6 @@ docker run --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io --mobile -n 5 - [ ] Бонус 1 про `dev.to` - [ ] Бонус 2 про `Falcon` - ## Bonus 1. Аудит dev.to Теперь, когда у вас сформировалась интуиция по работе с `HTTP/2` и `server-push`, постройте и проанализируйте отчёт `WebPageTest` для сайта `dev.to` (на проде). diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index df60029..8a010a0 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -7,6 +7,16 @@ def index return handle_user_or_organization_or_podcast_index if params[:username] return handle_tag_index if params[:tag] + 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(", ") + handle_base_index end diff --git a/app/views/layouts/_top_bar.html.erb b/app/views/layouts/_top_bar.html.erb index bf2750f..fca6cfe 100644 --- a/app/views/layouts/_top_bar.html.erb +++ b/app/views/layouts/_top_bar.html.erb @@ -13,11 +13,11 @@ WRITE A POST - <%= inline_svg("connect.svg", size: "100% * 100%") %> + <%= image_tag("connect.svg", size: "100% * 100%") %>
- <%= inline_svg("bell.svg", size: "100% * 100%") %> + <%= image_tag("bell.svg", size: "100% * 100%") %>