render-later 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ed24ef6ef278f6b32265a03b669da4dfd2d89a5
4
- data.tar.gz: 679cb4db160e2f287656ccfe4ef1b8e05484af3f
3
+ metadata.gz: e1124bb4e36a64975fbdc6b79b35bbccf1afaf03
4
+ data.tar.gz: b8d83484ce27bb6a415238ecc88069e126bad8d6
5
5
  SHA512:
6
- metadata.gz: ce8efe885bf50f0cb29b4070d739f812a1049109567198b39fd4f90e76d80def1b7c2771c5ea8fe658051673ad67c8f3af5cc61d46b883d6ac6cc06b79fcb8ec
7
- data.tar.gz: 6db85e49c804372d9e887e288ce9390075410e2123e7e6089f57b128ac389f87fc5a86a4f5a848fe9bd5f177d15554787eb853369127b423de6c35df6de94af4
6
+ metadata.gz: 860835d8c1a20743fd278850de9a5f66cb3d9131d8829a41a3eb6dd43611d98f4c4586ef17b8d792da564344db65b2fc7eb842622c7a8b4b5512a540ae9d513d
7
+ data.tar.gz: 63718790b5cac1da165f5e22be2960ea41370302d65cfd46f7b416aeb42b3a73a557c1299fa26a74350faba3cc4ef11244b959d6e65c7e66480e7d08038dc0ec
data/README.md CHANGED
@@ -84,8 +84,25 @@ Phusion Passenger | ✔️ |
84
84
  Unicorn | ✔️ | _with `tcp_nopush: false`_
85
85
  puma | ✔️ |
86
86
  WEBrick | ❌ | _default for `rails s`_
87
+ Thin | ❌ |
87
88
 
88
- To try it in development I recommend simply adding `gem 'puma'` to your `Gemfile` and `rails s` will use it. Though it's totally fine to work with a server which doesn't support streaming, you just won't benefit from the speed.
89
+ To try it in development, I recommend adding `gem 'unicorn-rails'` to your `Gemfile`'s development group and use `UNICORN_WORKERS=4 rails s` to start it. We need multiple processes in development to avoid blocking CSS requests during the page load. It's totally fine to develop with a single process or a server which doesn't support streaming, you just won't see the effects of the gem.
90
+
91
+ ### gzip
92
+
93
+ Unforunately I counldn't manage to make streaming works with gzip compression (provided by default in nginx), which means that if you're using nginx to compress your pages (and you should) this won't work, the page will be rendered all at once as before. I haven't investigated much but it seems to be because nginx need to have the whole body to compress it all at once and then start streaming the compressed body (but it's too late).
94
+
95
+ So the only workaround I have it to disable gzip compression for pages you want to stream, and no, it won't hurt performance that much. Sending 50kb html instead 6kb gzip is fine if it saves 3sec in render time.
96
+
97
+ Example:
98
+ ```
99
+ location / {
100
+ if ( $request_uri ~ ^/slow$ ) {
101
+ gzip off;
102
+ }
103
+ ...
104
+ }
105
+ ```
89
106
 
90
107
  #### Template Engine
91
108
  Like for web servers, some template engine in Rails doesn't support streaming and requires to generate the entire page before sending it on the wire. You will need to avoid them at least for the layout page which will contain the `render_now` statement.
@@ -26,6 +26,7 @@ module RenderLater
26
26
  concat content_tag('script', raw("rl_insert('rl-#{key}', '#{j capture(&block)}');\n"))
27
27
  end
28
28
  nil
29
+ rescue Errno::EPIPE
29
30
  end
30
31
 
31
32
  private
@@ -38,7 +39,11 @@ module RenderLater
38
39
  end
39
40
 
40
41
  def deferred_objects
41
- request.instance_variable_get(:@deferred_objects) || {}
42
+ if request.instance_variable_defined?(:@deferred_objects)
43
+ request.instance_variable_get(:@deferred_objects)
44
+ else
45
+ {}
46
+ end
42
47
  end
43
48
  end
44
49
  end
@@ -1,3 +1,3 @@
1
1
  module RenderLater
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.11"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "minitest", "~> 5.0"
25
- spec.add_development_dependency "rails", ">= 4.0"
25
+ spec.add_development_dependency "rails", "~> 4.0"
26
26
  spec.add_development_dependency "puma"
27
27
  spec.add_development_dependency "poltergeist"
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render-later
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Jarthon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-16 00:00:00.000000000 Z
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '4.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '4.0'
69
69
  - !ruby/object:Gem::Dependency
@@ -139,3 +139,4 @@ signing_key:
139
139
  specification_version: 4
140
140
  summary: Defer rendering of slow parts to the end of the page
141
141
  test_files: []
142
+ has_rdoc: