seo_cache 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +56 -26
- data/lib/seo_cache/page_caching.rb +3 -3
- data/lib/seo_cache/version.rb +1 -1
- data/lib/seo_cache.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71f9d913131751f275f89dc2dfaa5efa2c7a7459b6a086c16129576bac9a202e
|
4
|
+
data.tar.gz: 4977d0738e9b3f2012e3759326c010be91c48d081e3f470eb4d002fc7daf9541
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ddf8e5685420b8a12a50f81846bef821687b9d58757ceb93bc4aae6b177390bf3ca965bbcf4ace82b1407296a06e24220f66fa933162006da4e891c05fe9c2b
|
7
|
+
data.tar.gz: 755dd4c9e0e210e215c41eca0451c5f7c9b1385238a1169d1b739cbb1b5c25de71d55e9f6fe0119e46361b805df2e7ac769b81679b509063727e8af443c160db
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
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
|
-
|
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
|
-
|
51
|
+
```ruby
|
52
|
+
SeoCache.cache_mode = 'memory'
|
53
|
+
```
|
50
54
|
|
51
|
-
|
55
|
+
Cache path (**required**):
|
52
56
|
|
53
|
-
|
57
|
+
```ruby
|
58
|
+
SeoCache.cache_path = Rails.root.join('public', 'seo_cache')
|
59
|
+
```
|
54
60
|
|
55
|
-
Redis URL (required if memory cache):
|
56
|
-
|
57
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
70
|
-
|
81
|
+
```ruby
|
82
|
+
SeoCache.log_missed_cache = true
|
83
|
+
```
|
84
|
+
|
71
85
|
URLs to blacklist:
|
72
86
|
|
73
|
-
|
74
|
-
|
87
|
+
```ruby
|
88
|
+
SeoCache.blacklist_params = %w[^/assets/.* ^/admin.*]
|
89
|
+
```
|
90
|
+
|
75
91
|
Params to blacklist:
|
76
92
|
|
77
|
-
|
78
|
-
|
93
|
+
```ruby
|
94
|
+
SeoCache.blacklist_urls = %w[page]
|
95
|
+
```
|
96
|
+
|
79
97
|
URLs to whitelist:
|
80
98
|
|
81
|
-
|
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
|
-
|
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
|
-
|
90
|
-
|
111
|
+
```ruby
|
112
|
+
SeoCache.extensions_to_ignore = [<your_list>]
|
113
|
+
```
|
114
|
+
|
91
115
|
List of bot agents (already defined):
|
92
116
|
|
93
|
-
|
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
|
-
|
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.
|
47
|
+
SeoCache.cache_path
|
48
48
|
end
|
49
49
|
|
50
50
|
def default_extension
|
51
|
-
SeoCache.
|
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.
|
58
|
+
URI::Parser.new.unescape(path.chomp('/'))
|
59
59
|
end
|
60
60
|
|
61
61
|
if File.extname(name).empty?
|
data/lib/seo_cache/version.rb
CHANGED
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 :
|
24
|
-
self.
|
23
|
+
mattr_accessor :cache_path
|
24
|
+
self.cache_path = ''
|
25
25
|
|
26
|
-
mattr_accessor :
|
27
|
-
self.
|
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.
|
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-
|
11
|
+
date: 2019-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|