seo_cache 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a029127389aa4942e27c5fbca325e56c020dfe4d35ec743034649e45700b71f
4
- data.tar.gz: cb8f7123d7ef7a959e86f53d65c127b4195cfc2b3c21938bf0fb31c6fdcbf507
3
+ metadata.gz: 71f9d913131751f275f89dc2dfaa5efa2c7a7459b6a086c16129576bac9a202e
4
+ data.tar.gz: 4977d0738e9b3f2012e3759326c010be91c48d081e3f470eb4d002fc7daf9541
5
5
  SHA512:
6
- metadata.gz: bd0f5a06df0b92a34304fad8893e3b708ef5142bd62509664dba5689fab503ffa1ae7a50901c3ee14f626c92a4d0b3994a017989e3024c8b2e6dd0083cbe47e5
7
- data.tar.gz: 7d1e4891181adb3b9deb3cb9c7773b9328befcebfc237f4c76ce3857b6c673751a14c72403126852782726c3b2998fb3253bf7a346d3f4f4f385542b538547bf
6
+ metadata.gz: 6ddf8e5685420b8a12a50f81846bef821687b9d58757ceb93bc4aae6b177390bf3ca965bbcf4ace82b1407296a06e24220f66fa933162006da4e891c05fe9c2b
7
+ data.tar.gz: 755dd4c9e0e210e215c41eca0451c5f7c9b1385238a1169d1b739cbb1b5c25de71d55e9f6fe0119e46361b805df2e7ac769b81679b509063727e8af443c160db
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /doc/
8
8
  /pkg/
9
9
  /spec/reports/
10
+ /spec/data/
10
11
  /tmp/
11
12
  .ruby-version
12
13
  .ruby-gemset
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.4.0
2
+
3
+ - Complete README
4
+ - Add new tests to cover disk and memory
5
+ - Remove "disk_" prefix from disk_cache_path and disk_cache_extension
6
+
1
7
  ## 0.3.0
2
8
 
3
9
  - Add more examples in README
data/README.md CHANGED
@@ -42,61 +42,91 @@ Rails.application.config.middleware.use SeoCache::Middleware
42
42
 
43
43
  Chrome path (**required**) (`disk` or `memory`):
44
44
 
45
- SeoCache.chrome_path = Rails.env.development? ? '/usr/bin/chromium-browser' : '/usr/bin/chromium'
45
+ ```ruby
46
+ SeoCache.chrome_path = Rails.env.development? ? '/usr/bin/chromium-browser' : '/usr/bin/chromium'
47
+ ```
46
48
 
47
49
  Choose a cache mode (`memory` (default) or `disk`):
48
50
 
49
- SeoCache.cache_mode = 'memory'
51
+ ```ruby
52
+ SeoCache.cache_mode = 'memory'
53
+ ```
50
54
 
51
- Disk cache path (required if disk cache):
55
+ Cache path (**required**):
52
56
 
53
- SeoCache.disk_cache_path = Rails.root.join('public', 'seo_cache')
57
+ ```ruby
58
+ SeoCache.cache_path = Rails.root.join('public', 'seo_cache')
59
+ ```
54
60
 
55
- Redis URL (required if memory cache):
56
-
57
- SeoCache.redis_url = "redis://localhost:6379/"
61
+ Redis URL (**required** if memory cache):
62
+
63
+ ```ruby
64
+ SeoCache.redis_url = "redis://localhost:6379/"
65
+ ```
58
66
 
59
67
  Redis prefix:
60
-
61
- SeoCache.redis_namespace = '_my_project:seo_cache'
68
+
69
+ ```ruby
70
+ SeoCache.redis_namespace = '_my_project:seo_cache'
71
+ ```
62
72
 
63
73
  Specific log file (if you want to log missed cache urls):
64
74
 
65
- SeoCache.logger_path = Rails.root.join('log', 'seo_cache.log')
75
+ ```ruby
76
+ SeoCache.logger_path = Rails.root.join('log', 'seo_cache.log')
77
+ ```
66
78
 
67
79
  Activate missed cache urls:
68
80
 
69
- SeoCache.log_missed_cache = true
70
-
81
+ ```ruby
82
+ SeoCache.log_missed_cache = true
83
+ ```
84
+
71
85
  URLs to blacklist:
72
86
 
73
- SeoCache.blacklist_params = %w[^/assets/.* ^/admin.*]
74
-
87
+ ```ruby
88
+ SeoCache.blacklist_params = %w[^/assets/.* ^/admin.*]
89
+ ```
90
+
75
91
  Params to blacklist:
76
92
 
77
- SeoCache.blacklist_urls = %w[page]
78
-
93
+ ```ruby
94
+ SeoCache.blacklist_urls = %w[page]
95
+ ```
96
+
79
97
  URLs to whitelist:
80
98
 
81
- SeoCache.whitelist_urls = []
82
-
99
+ ```ruby
100
+ SeoCache.whitelist_urls = []
101
+ ```
102
+
83
103
  Parameter to add manually to the URl to force page caching, if you want to cache a specific URL (e.g. `https://<my_website>/?_seo_cache_=true`):
84
104
 
85
- SeoCache.force_cache_url_param = '_seo_cache_'
86
-
105
+ ```ruby
106
+ SeoCache.force_cache_url_param = '_seo_cache_'
107
+ ```
108
+
87
109
  URL extension to ignore when caching (already defined):
88
110
 
89
- SeoCache.extensions_to_ignore = [<your_list>]
90
-
111
+ ```ruby
112
+ SeoCache.extensions_to_ignore = [<your_list>]
113
+ ```
114
+
91
115
  List of bot agents (already defined):
92
116
 
93
- SeoCache.crawler_user_agents = [<your_list>]
117
+ ```ruby
118
+ SeoCache.crawler_user_agents = [<your_list>]
119
+ ```
94
120
 
95
121
  Parameter added to URL when generating the page, avoid infinite rendering (override only if already used):
96
122
 
97
- SeoCache.prerender_url_param = '_prerender_'
123
+ ```ruby
124
+ SeoCache.prerender_url_param = '_prerender_'
125
+ ```
98
126
 
99
- Be aware, JS will be render twice: once by server rendering and once by client. For React, this not a problem but with jQuery plugins, it can duplicate elements in the page (you have to check the redundancy).
127
+ Be aware, JS will be render twice: once by server rendering and once by client. For React, this not a problem but with jQuery plugins, it can duplicate elements in the page (you have to check the redundancy).
128
+
129
+ Disk cache is recommended by default. Nginx will directly fetch file on disk. The TTFB (time to first byte) will be under 200ms :). You can use memory cache if you have lot of RAM.
100
130
 
101
131
  ## Automatic caching
102
132
 
@@ -122,7 +152,7 @@ You can add the `force_cache: true` option to `SeoCache::PopulateCache` for over
122
152
 
123
153
  If you use disk caching, add to your Nginx configuration:
124
154
 
125
- ```
155
+ ```nginx
126
156
  location / {
127
157
  # Ignore url with blacklisted params (e.g. page)
128
158
  if ($arg_page) {
@@ -44,18 +44,18 @@ module SeoCache
44
44
  private
45
45
 
46
46
  def cache_directory
47
- SeoCache.disk_cache_path
47
+ SeoCache.cache_path
48
48
  end
49
49
 
50
50
  def default_extension
51
- SeoCache.disk_cache_extension
51
+ SeoCache.cache_extension
52
52
  end
53
53
 
54
54
  def cache_file(path, extension)
55
55
  name = if path.empty? || path =~ %r{\A/+\z}
56
56
  '/index'
57
57
  else
58
- URI.parser.unescape(path.chomp('/'))
58
+ URI::Parser.new.unescape(path.chomp('/'))
59
59
  end
60
60
 
61
61
  if File.extname(name).empty?
@@ -1,3 +1,3 @@
1
1
  module SeoCache
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
data/lib/seo_cache.rb CHANGED
@@ -20,11 +20,11 @@ module SeoCache
20
20
  mattr_accessor :cache_mode # disk or memory
21
21
  self.cache_mode = 'memory'
22
22
 
23
- mattr_accessor :disk_cache_path
24
- self.disk_cache_path = ''
23
+ mattr_accessor :cache_path
24
+ self.cache_path = ''
25
25
 
26
- mattr_accessor :disk_cache_extension
27
- self.disk_cache_extension = '.html'
26
+ mattr_accessor :cache_extension
27
+ self.cache_extension = '.html'
28
28
 
29
29
  mattr_accessor :redis_url
30
30
  self.redis_url = 'redis://localhost:6379/'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seo_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - FloXcoder
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-04 00:00:00.000000000 Z
11
+ date: 2019-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport