seo_cache 1.0.3 → 1.0.4

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: f2c6084cfed22c86d8dae948445d042fb5bcccd8a01afac54974dfaa96181f20
4
- data.tar.gz: a71c76d0d492bb9058d68a81ae8c5aa3170ef09d64192818d6f3a573453f18c9
3
+ metadata.gz: 7ee65da1765c3f78ac9f0ede65e7271880378217d20deeed9df1476f524f5c9d
4
+ data.tar.gz: 473a51c49bab2d40fab978611b13e872185d89cb834d57352b5ca5cb10aa627d
5
5
  SHA512:
6
- metadata.gz: 454155f0bcc296c6ccd1d7d3eafa90d5a83f17a38c1d24cdd4d52a7ae44eb2dca7dc493fad4233c30b33fb6183028a39bb7e8c60baa55a61533b22ac239267fd
7
- data.tar.gz: cf60d5d45b01fc2de32ee0963bd086e48859adcc6abcfee8921dcade7a38bdaae09727dfa025a49c0116f36fcff76f6adb651000293f6514db13d2415ccb223c
6
+ metadata.gz: f0c783ce23dd0122988c73e44110fd2173033a67bdf77029d3c5ba57943b6abf343ae141d3c69b46ef1575366b05b185fdcaba50c3709a0b4a1ee99c8f34fa13
7
+ data.tar.gz: 9b056081949ce4207f996748d4750fe37c7128afe88341d81a6c2b0ea04f3024f051eabb6fff4cca68f0e7976c1b476076ecce4548a7a510696a04692dbf241d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.4
2
+
3
+ - Add option to populate seo cache for multi-domains
4
+
1
5
  ## 1.0.3
2
6
 
3
7
  - Ensure page rendered status is present after head element
data/README.md CHANGED
@@ -227,6 +227,8 @@ end
227
227
 
228
228
  You can add the `force_cache: true` option to `SeoCache::PopulateCache` for overwrite cached data.
229
229
 
230
+ If your website has several domains (.com, .fr, ...), you need to generate your urls for each locale (each key is the locale). And use the `with_locale_keys: true` option.
231
+
230
232
  If you want to execute only through a rake task, you can comment the line which include the middleware. keep all options configured and remove only the middleware. Thus all pages will be cached and SeoCache isn't called for pages not in cache.
231
233
  It's useful if you have a script which generates all website pages (based on sitemap for instance) and you run script every day.
232
234
 
@@ -275,6 +277,8 @@ location / {
275
277
  rewrite ^/(.*)/$ /$1 last;
276
278
 
277
279
  try_files /seo_cache/$uri/index$cache_extension /seo_cache/$uri$cache_extension /seo_cache/$uri $uri @rubyproxy;
280
+ # Or for multi-domains:
281
+ # try_files /seo_cache/fr/$uri/index$cache_extension /seo_cache/fr/$uri$cache_extension /seo_cache/fr/$uri $uri @rubyproxy;
278
282
  }
279
283
 
280
284
  location @rubyproxy {
@@ -11,23 +11,41 @@ module SeoCache
11
11
  @page_render = PageRender.new
12
12
  @page_caching = PageCaching.new
13
13
 
14
- @force_cache = options.fetch(:force_cache, false)
14
+ @force_cache = options.fetch(:force_cache, false)
15
+ @with_locale_keys = options.fetch(:with_locale_keys, false)
15
16
  end
16
17
 
17
18
  def perform
18
- @paths.each do |path|
19
- next if @page_caching.cache_exists?(path) && !@force_cache
20
-
21
- url = @host + path
22
- url += path.include?('?') ? '&' : '?'
23
- url += "#{SeoCache.prerender_url_param}=true"
24
-
25
- page_source = @page_render.get(url, false)
26
- @page_caching.cache(page_source, path) if page_source
19
+ if @with_locale_keys
20
+ @paths.each do |locale, paths|
21
+ paths.each do |path|
22
+ generate_cache(path, locale)
23
+ end
24
+ end
25
+ else
26
+ @paths.each do |path|
27
+ generate_cache(path)
28
+ end
27
29
  end
28
30
 
29
31
  ensure
30
32
  @page_render.close_connection
31
33
  end
34
+
35
+ private
36
+
37
+ def generate_cache(path, locale = nil)
38
+ return if @page_caching.cache_exists?(path) && !@force_cache
39
+
40
+ url = @host + path
41
+ url += path.include?('?') ? '&' : '?'
42
+ url += "#{SeoCache.prerender_url_param}=true"
43
+
44
+ page_source = @page_render.get(url, false)
45
+ return unless page_source
46
+
47
+ path_cache_key = locale ? "/#{locale}#{path}" : path
48
+ @page_caching.cache(page_source, path_cache_key)
49
+ end
32
50
  end
33
51
  end
@@ -1,3 +1,3 @@
1
1
  module SeoCache
2
- VERSION = '1.0.3'.freeze
2
+ VERSION = '1.0.4'.freeze
3
3
  end
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.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - FloXcoder
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-01 00:00:00.000000000 Z
11
+ date: 2021-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -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.16
232
+ rubygems_version: 3.2.17
233
233
  signing_key:
234
234
  specification_version: 4
235
235
  summary: Cache dedicated for SEO with Javascript rendering