seo_cache 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/seo_cache/middleware.rb +10 -4
- data/lib/seo_cache/page_caching.rb +12 -12
- data/lib/seo_cache/populate_cache.rb +2 -3
- data/lib/seo_cache/version.rb +1 -1
- data/seo_cache.gemspec +2 -2
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7286c3adfbf791c5b7091e4f689e4fbfe69bef35973e01c3f50f4d2fa3c8b9bb
|
4
|
+
data.tar.gz: 4b27b16b60243f1f428ad36aa6e00d9699d1e71afe42100c1e643ed56b06ba4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66ab72c0aea1d7029ebd8f39e90b8aa5b36e8d15951b0359824989175e56098d380882fe0e05c8a90e9faa1fbf4b43d2a9acd53ec9aea67aebf3ed87399858d2
|
7
|
+
data.tar.gz: 60121490b30d93c0fcd204f3dcf5c06bf3c9a14aa5e76eb19a9cf9986ff119bfb72b6e6ead3a119f33479334eeb5e8831b99bf68f56c7ad54ad44bfd20741eb8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 1.1.0
|
2
|
+
|
3
|
+
- Update dependencies
|
4
|
+
|
5
|
+
## 1.0.7
|
6
|
+
|
7
|
+
- Use new syntax to check if Redis key exists
|
8
|
+
|
9
|
+
## 1.0.6
|
10
|
+
|
11
|
+
- Logs only missed cache for success response
|
12
|
+
|
13
|
+
## 1.0.5
|
14
|
+
|
15
|
+
- Use correct path for index page with multiple domain names
|
16
|
+
|
1
17
|
## 1.0.4
|
2
18
|
|
3
19
|
- Add option to populate seo cache for multi-domains
|
data/lib/seo_cache/middleware.rb
CHANGED
@@ -36,9 +36,15 @@ module SeoCache
|
|
36
36
|
else
|
37
37
|
Thread.new do
|
38
38
|
prerender_data = page_render(env)
|
39
|
-
# Extract status from render page or return
|
40
|
-
status = prerender_data&.scan(/<!--status:(\d+)-->/)&.last&.first
|
41
|
-
|
39
|
+
# Extract status from render page or return success (200)
|
40
|
+
status = prerender_data&.scan(/<!--status:(\d+)-->/)&.last&.first || 200
|
41
|
+
|
42
|
+
if SeoCache.log_missed_cache && status.to_s.start_with?('2')
|
43
|
+
env_request = Rack::Request.new(env)
|
44
|
+
SeoCache.log("missed cache : #{env_request.path} (User agent: #{env_request.user_agent})")
|
45
|
+
end
|
46
|
+
|
47
|
+
after_render(env, prerender_data, status)
|
42
48
|
end
|
43
49
|
end
|
44
50
|
elsif prerender_params?(env)
|
@@ -94,7 +100,7 @@ module SeoCache
|
|
94
100
|
return false if SeoCache.blacklist_params.present? && SeoCache.blacklist_params.any? { |param| query_params.has_key?(param) }
|
95
101
|
|
96
102
|
# if it is a bot and is requesting a resource...don't prerender
|
97
|
-
return false if @extensions_to_ignore.any? { |extension| request.fullpath.include?
|
103
|
+
return false if @extensions_to_ignore.any? { |extension| request.fullpath.include?(extension) }
|
98
104
|
|
99
105
|
# if it is a bot and not requesting a resource and is not whitelisted...don't prerender
|
100
106
|
return false if SeoCache.whitelist_urls.present? && SeoCache.whitelist_urls.all? { |whitelisted| !Regexp.new(whitelisted).match(request.fullpath) }
|
@@ -17,12 +17,12 @@ module SeoCache
|
|
17
17
|
@redis.get(cache_path(path, extension)) if SeoCache.memory_cache? && @redis
|
18
18
|
end
|
19
19
|
|
20
|
-
def cache(content, path, extension = nil, gzip = Zlib::BEST_COMPRESSION)
|
20
|
+
def cache(content, path, locale_domain = nil, extension = nil, gzip = Zlib::BEST_COMPRESSION)
|
21
21
|
instrument :write_page, path do
|
22
22
|
if SeoCache.memory_cache? && @redis
|
23
|
-
write_to_memory(content, cache_path(path, extension))
|
23
|
+
write_to_memory(content, cache_path(path, extension, locale_domain))
|
24
24
|
else
|
25
|
-
write_to_disk(content, cache_path(path, extension), gzip)
|
25
|
+
write_to_disk(content, cache_path(path, extension, locale_domain), gzip)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -35,7 +35,7 @@ module SeoCache
|
|
35
35
|
|
36
36
|
def cache_exists?(path)
|
37
37
|
if SeoCache.memory_cache? && @redis
|
38
|
-
@redis.exists(cache_path(path))
|
38
|
+
@redis.exists?(cache_path(path))
|
39
39
|
else
|
40
40
|
File.exist?(cache_path(path))
|
41
41
|
end
|
@@ -51,22 +51,22 @@ module SeoCache
|
|
51
51
|
SeoCache.cache_extension
|
52
52
|
end
|
53
53
|
|
54
|
-
def cache_file(path, extension)
|
54
|
+
def cache_file(path, extension, locale_domain)
|
55
55
|
name = if path.empty? || path =~ %r{\A/+\z}
|
56
56
|
'/index'
|
57
57
|
else
|
58
58
|
URI::Parser.new.unescape(path.chomp('/'))
|
59
59
|
end
|
60
60
|
|
61
|
-
if
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
name = "#{locale_domain}/#{name}" if locale_domain
|
62
|
+
|
63
|
+
name += extension || default_extension if File.extname(name).empty?
|
64
|
+
|
65
|
+
name
|
66
66
|
end
|
67
67
|
|
68
|
-
def cache_path(path, extension = nil)
|
69
|
-
File.join(cache_directory, cache_file(path, extension))
|
68
|
+
def cache_path(path, extension = nil, locale_domain = nil)
|
69
|
+
File.join(cache_directory, cache_file(path, extension, locale_domain))
|
70
70
|
end
|
71
71
|
|
72
72
|
def write_to_memory(content, path)
|
@@ -34,7 +34,7 @@ module SeoCache
|
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
|
-
def generate_cache(path,
|
37
|
+
def generate_cache(path, locale_domain = nil)
|
38
38
|
return if @page_caching.cache_exists?(path) && !@force_cache
|
39
39
|
|
40
40
|
url = @host + path
|
@@ -44,8 +44,7 @@ module SeoCache
|
|
44
44
|
page_source = @page_render.get(url, false)
|
45
45
|
return unless page_source
|
46
46
|
|
47
|
-
|
48
|
-
@page_caching.cache(page_source, path_cache_key)
|
47
|
+
@page_caching.cache(page_source, path, locale_domain)
|
49
48
|
end
|
50
49
|
end
|
51
50
|
end
|
data/lib/seo_cache/version.rb
CHANGED
data/seo_cache.gemspec
CHANGED
@@ -25,8 +25,8 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_dependency 'railties', '>= 5'
|
26
26
|
spec.add_dependency 'redis', '~> 4'
|
27
27
|
spec.add_dependency 'redis-namespace', '~> 1'
|
28
|
-
spec.add_dependency 'selenium-webdriver', '
|
29
|
-
spec.add_dependency 'webdrivers', '
|
28
|
+
spec.add_dependency 'selenium-webdriver', '>= 3'
|
29
|
+
spec.add_dependency 'webdrivers', '>= 3'
|
30
30
|
|
31
31
|
spec.add_development_dependency 'bundler', '~> 2'
|
32
32
|
spec.add_development_dependency 'rake', '~> 13'
|
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: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FloXcoder
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -84,30 +84,30 @@ dependencies:
|
|
84
84
|
name: selenium-webdriver
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '3'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: webdrivers
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '3'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '3'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: bundler
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
229
|
- !ruby/object:Gem::Version
|
230
230
|
version: '0'
|
231
231
|
requirements: []
|
232
|
-
rubygems_version: 3.2.
|
232
|
+
rubygems_version: 3.2.29
|
233
233
|
signing_key:
|
234
234
|
specification_version: 4
|
235
235
|
summary: Cache dedicated for SEO with Javascript rendering
|