static-rails 0.0.13 → 0.0.14

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
  SHA256:
3
- metadata.gz: 03ce2ba0869984457f2559cbb246e1c5c4e7335ff2050fcde5d40b8bb7206d8d
4
- data.tar.gz: d77d6cc728e3b107d142ec2f8c72532a1d34e6bd26d44e1b7d6fbf6f4cde525d
3
+ metadata.gz: 2a6e7ad52cd960477f61b0faaa6364968844e8d2862714e35340531a12aa82e5
4
+ data.tar.gz: 0a66a78cfdec31a91354c8815e1ec612a44345230bfb5115cdd1afc999bbcc85
5
5
  SHA512:
6
- metadata.gz: 8edb6f4136b02e64b01e9ca46fb5322eb963a7ec3769b98aa93c71d8c22adb6f6232ef4660c16c049eb8f1ee58d702368918e6aeb5956202ff84605c3c690eb9
7
- data.tar.gz: 0452ae2dd5985d8cd7f741a637888262da0d08126edaafa0bafafd0de2bfcbf27b79d033ee41e017a65753a1556df20d37ff25faccbad8e94b71bc60b16f0ace
6
+ metadata.gz: fca6f6a4ffa3a2893019d583853d1e790e8a28e90fb6140a53ce4f5dfdf4b34abfb5d9a350f3a4e5d6e5245a3461f6b303f62208cd55b9158c1256e38f35f1f8
7
+ data.tar.gz: 4d03d6226092c97f5fe9f35283c77d4544f3addb4766d42a01eb6cd69568763ab24ff5220181e0f7b5f7cce69722b073367b098bd1e525c37923b449ca460903
@@ -1,3 +1,8 @@
1
+ ## 0.0.14
2
+
3
+ * HTML & XML won't be cached by default in production
4
+ [#20](https://github.com/testdouble/static-rails/pull/20)
5
+
1
6
  ## 0.0.13
2
7
 
3
8
  * 404 pages served in production via a site's `compile_404_file_path` setting
@@ -1,50 +1,50 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- static-rails (0.0.13)
4
+ static-rails (0.0.14)
5
5
  rack-proxy (~> 0.6)
6
6
  railties (>= 5.0.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (6.0.3.2)
12
- actionview (= 6.0.3.2)
13
- activesupport (= 6.0.3.2)
11
+ actionpack (6.0.3.3)
12
+ actionview (= 6.0.3.3)
13
+ activesupport (= 6.0.3.3)
14
14
  rack (~> 2.0, >= 2.0.8)
15
15
  rack-test (>= 0.6.3)
16
16
  rails-dom-testing (~> 2.0)
17
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (6.0.3.2)
19
- activesupport (= 6.0.3.2)
18
+ actionview (6.0.3.3)
19
+ activesupport (= 6.0.3.3)
20
20
  builder (~> 3.1)
21
21
  erubi (~> 1.4)
22
22
  rails-dom-testing (~> 2.0)
23
23
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- activesupport (6.0.3.2)
24
+ activesupport (6.0.3.3)
25
25
  concurrent-ruby (~> 1.0, >= 1.0.2)
26
26
  i18n (>= 0.7, < 2)
27
27
  minitest (~> 5.1)
28
28
  tzinfo (~> 1.1)
29
29
  zeitwerk (~> 2.2, >= 2.2.2)
30
- ast (2.4.0)
30
+ ast (2.4.1)
31
31
  builder (3.2.4)
32
- concurrent-ruby (1.1.6)
32
+ concurrent-ruby (1.1.7)
33
33
  crass (1.0.6)
34
34
  erubi (1.9.0)
35
- i18n (1.8.3)
35
+ i18n (1.8.5)
36
36
  concurrent-ruby (~> 1.0)
37
- loofah (2.6.0)
37
+ loofah (2.7.0)
38
38
  crass (~> 1.0.2)
39
39
  nokogiri (>= 1.5.9)
40
40
  method_source (1.0.0)
41
41
  mini_portile2 (2.4.0)
42
- minitest (5.14.1)
42
+ minitest (5.14.2)
43
43
  nokogiri (1.10.10)
44
44
  mini_portile2 (~> 2.4.0)
45
- parallel (1.19.1)
46
- parser (2.7.1.3)
47
- ast (~> 2.4.0)
45
+ parallel (1.19.2)
46
+ parser (2.7.1.4)
47
+ ast (~> 2.4.1)
48
48
  rack (2.2.3)
49
49
  rack-proxy (0.6.5)
50
50
  rack
@@ -55,33 +55,34 @@ GEM
55
55
  nokogiri (>= 1.6)
56
56
  rails-html-sanitizer (1.3.0)
57
57
  loofah (~> 2.3)
58
- railties (6.0.3.2)
59
- actionpack (= 6.0.3.2)
60
- activesupport (= 6.0.3.2)
58
+ railties (6.0.3.3)
59
+ actionpack (= 6.0.3.3)
60
+ activesupport (= 6.0.3.3)
61
61
  method_source
62
62
  rake (>= 0.8.7)
63
63
  thor (>= 0.20.3, < 2.0)
64
64
  rainbow (3.0.0)
65
65
  rake (13.0.1)
66
- regexp_parser (1.7.1)
66
+ regexp_parser (1.8.0)
67
67
  rexml (3.2.4)
68
- rubocop (0.85.1)
68
+ rubocop (0.91.1)
69
69
  parallel (~> 1.10)
70
- parser (>= 2.7.0.1)
70
+ parser (>= 2.7.1.1)
71
71
  rainbow (>= 2.2.2, < 4.0)
72
72
  regexp_parser (>= 1.7)
73
73
  rexml
74
- rubocop-ast (>= 0.0.3)
74
+ rubocop-ast (>= 0.4.0, < 1.0)
75
75
  ruby-progressbar (~> 1.7)
76
76
  unicode-display_width (>= 1.4.0, < 2.0)
77
- rubocop-ast (0.0.3)
78
- parser (>= 2.7.0.1)
79
- rubocop-performance (1.6.1)
80
- rubocop (>= 0.71.0)
77
+ rubocop-ast (0.4.2)
78
+ parser (>= 2.7.1.4)
79
+ rubocop-performance (1.8.1)
80
+ rubocop (>= 0.87.0)
81
+ rubocop-ast (>= 0.4.0)
81
82
  ruby-progressbar (1.10.1)
82
- standard (0.4.7)
83
- rubocop (~> 0.85.0)
84
- rubocop-performance (~> 1.6.0)
83
+ standard (0.6.2)
84
+ rubocop (= 0.91.1)
85
+ rubocop-performance (= 1.8.1)
85
86
  thor (1.0.1)
86
87
  thread_safe (0.3.6)
87
88
  tzinfo (1.2.7)
@@ -54,8 +54,7 @@ module StaticRails
54
54
  end
55
55
 
56
56
  def serve(request, filepath, content_headers)
57
- original, request.path_info =
58
- request.path_info, ::Rack::Utils.escape_path(filepath).b
57
+ original, request.path_info = request.path_info, ::Rack::Utils.escape_path(filepath).b
59
58
 
60
59
  @file_server.call(request.env).tap do |status, headers, body|
61
60
  # Omit Content-Encoding/Type/etc headers for 304 Not Modified
@@ -53,6 +53,17 @@ module StaticRails
53
53
  return unless file
54
54
  file_handler.serve(req, *file).tap do |result|
55
55
  result[0] = status_override unless status_override.nil?
56
+ override_cache_control_if_we_probably_shouldnt_cache!(file, result[1])
57
+ end
58
+ end
59
+
60
+ PROBABLY_SHOULDNT_CACHE_MIME_TYPES = [
61
+ "text/html", "application/xml", "application/rss+xml"
62
+ ]
63
+ def override_cache_control_if_we_probably_shouldnt_cache!(file, headers = {})
64
+ mime_type = file[1]["Content-Type"]
65
+ if PROBABLY_SHOULDNT_CACHE_MIME_TYPES.include?(mime_type)
66
+ headers["cache-control"] = "no-cache, no-store"
56
67
  end
57
68
  end
58
69
  end
@@ -1,3 +1,3 @@
1
1
  module StaticRails
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: static-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-17 00:00:00.000000000 Z
11
+ date: 2020-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties