seo_cache 0.19.0 → 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: 93939e53687c186d003b4b09abed06bcf1b6ac0a63b808c3a7abfadd7e6531cb
4
- data.tar.gz: 4d362ee26521e0ebb55b61c15e6b9d5e6c9e19877e57ead9cfab9765c4310142
3
+ metadata.gz: 7ee65da1765c3f78ac9f0ede65e7271880378217d20deeed9df1476f524f5c9d
4
+ data.tar.gz: 473a51c49bab2d40fab978611b13e872185d89cb834d57352b5ca5cb10aa627d
5
5
  SHA512:
6
- metadata.gz: fc485c1ea013d77fcf9337c3423bacec563701b319d79b4949304f6bf51fe78c54a3553cdf875b8067e60c1c9c8ae3667dfeec0ee8f29f3991079d5662c3ffa7
7
- data.tar.gz: 1d634743d69e52965d9c450b046dc19edabd88b92783c567c460a11b7407473d395600775cd5aaff31f96db5b68fa5143954f90fa7b154fbccf76f3f9284e00b
6
+ metadata.gz: f0c783ce23dd0122988c73e44110fd2173033a67bdf77029d3c5ba57943b6abf343ae141d3c69b46ef1575366b05b185fdcaba50c3709a0b4a1ee99c8f34fa13
7
+ data.tar.gz: 9b056081949ce4207f996748d4750fe37c7128afe88341d81a6c2b0ea04f3024f051eabb6fff4cca68f0e7976c1b476076ecce4548a7a510696a04692dbf241d
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. iOS]
28
+ - Browser [e.g. chrome, safari]
29
+ - Version [e.g. 22]
30
+
31
+ **Smartphone (please complete the following information):**
32
+ - Device: [e.g. iPhone6]
33
+ - OS: [e.g. iOS8.1]
34
+ - Browser [e.g. stock browser, safari]
35
+ - Version [e.g. 22]
36
+
37
+ **Additional context**
38
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,14 @@
1
+ ### Summary
2
+
3
+ Provide a general description of the code changes in your pull
4
+ request... were there any bugs you had fixed? If so, mention them. If
5
+ these bugs have open GitHub issues, be sure to tag them here as well,
6
+ to keep the conversation linked together.
7
+
8
+ ### Other Information
9
+
10
+ If there's anything else that's important and relevant to your pull
11
+ request, mention that information here. This could include
12
+ benchmarks, or other information.
13
+
14
+ Thanks for contributing to SeoCache!
data/.rubocop.yml CHANGED
@@ -1,18 +1,20 @@
1
1
  # Documentation
2
2
  # https://github.com/bbatsov/rubocop/blob/master/config/default.yml
3
- # http://rubocop.readthedocs.io/en/latest
3
+ # http://rubocop.readthedocs.io/en/latest
4
+
5
+ require:
6
+ - rubocop-rails
7
+ - rubocop-rspec
8
+ - rubocop-performance
4
9
 
5
10
  AllCops:
6
- TargetRubyVersion: 2.6
11
+ TargetRubyVersion: 3.0
7
12
 
8
13
  Bundler/OrderedGems:
9
14
  Enabled: false
10
15
 
11
- Layout/HashAlignment:
12
- Enabled: false
13
-
14
- Layout/ParameterAlignment:
15
- Enabled: false
16
+ Gemspec/DateAssignment:
17
+ Enabled: true
16
18
 
17
19
  Layout/CaseIndentation:
18
20
  Enabled: false
@@ -42,9 +44,15 @@ Layout/FirstArrayElementIndentation:
42
44
  Layout/FirstHashElementIndentation:
43
45
  Enabled: false
44
46
 
47
+ Layout/HashAlignment:
48
+ Enabled: false
49
+
45
50
  Layout/LeadingCommentSpace:
46
51
  Enabled: false
47
52
 
53
+ Layout/LineLength:
54
+ Enabled: false
55
+
48
56
  Layout/MultilineBlockLayout:
49
57
  Enabled: false
50
58
 
@@ -57,20 +65,73 @@ Layout/MultilineMethodCallIndentation:
57
65
  Layout/MultilineOperationIndentation:
58
66
  Enabled: false
59
67
 
68
+ Layout/ParameterAlignment:
69
+ Enabled: false
70
+
60
71
  Layout/SpaceAroundOperators:
61
72
  Enabled: false
62
73
 
74
+ Layout/SpaceBeforeBrackets:
75
+ Enabled: true
76
+
63
77
  Layout/SpaceInLambdaLiteral:
64
78
  Enabled: false
65
79
 
66
80
  Layout/TrailingWhitespace:
67
81
  Enabled: false
68
82
 
83
+ Lint/AmbiguousAssignment:
84
+ Enabled: true
85
+
69
86
  Lint/AmbiguousBlockAssociation:
70
87
  Enabled: false
71
88
 
89
+ Lint/DeprecatedConstants:
90
+ Enabled: true
91
+
92
+ Lint/DuplicateBranch:
93
+ Enabled: true
94
+
95
+ Lint/DuplicateRegexpCharacterClassElement:
96
+ Enabled: true
97
+
98
+ Lint/EmptyBlock:
99
+ Enabled: true
100
+
101
+ Lint/EmptyClass:
102
+ Enabled: true
103
+
104
+ Lint/LambdaWithoutLiteralBlock:
105
+ Enabled: true
106
+
107
+ Lint/NoReturnInBeginEndBlocks:
108
+ Enabled: true
109
+
110
+ Lint/NumberedParameterAssignment:
111
+ Enabled: true
112
+
113
+ Lint/OrAssignmentToConstant:
114
+ Enabled: true
115
+
116
+ Lint/RedundantDirGlobSort:
117
+ Enabled: true
118
+
119
+ Lint/SymbolConversion:
120
+ Enabled: true
121
+
122
+ Lint/ToEnumArguments:
123
+ Enabled: true
124
+
125
+ Lint/TripleQuotes:
126
+ Enabled: true
127
+
128
+ Lint/UnexpectedBlockArity:
129
+ Enabled: true
130
+
131
+ Lint/UnmodifiedReduceAccumulator:
132
+ Enabled: true
133
+
72
134
  Metrics/AbcSize:
73
- # The ABC size is a calculated magnitude, so this number can be a Fixnum or a Float.
74
135
  Max: 240
75
136
 
76
137
  Metrics/BlockLength:
@@ -80,14 +141,14 @@ Metrics/BlockNesting:
80
141
  Max: 4
81
142
 
82
143
  Metrics/ClassLength:
83
- CountComments: false # count full line comments?
144
+ CountComments: false
84
145
  Max: 600
85
146
 
86
147
  Metrics/CyclomaticComplexity:
87
148
  Enabled: false
88
149
 
89
150
  Metrics/MethodLength:
90
- CountComments: false # count full line comments?
151
+ CountComments: false
91
152
  Max: 120
92
153
 
93
154
  Metrics/PerceivedComplexity:
@@ -96,6 +157,168 @@ Metrics/PerceivedComplexity:
96
157
  Naming/RescuedExceptionsVariableName:
97
158
  Enabled: false
98
159
 
160
+ Performance/AncestorsInclude:
161
+ Enabled: true
162
+
163
+ Performance/BigDecimalWithNumericArgument:
164
+ Enabled: true
165
+
166
+ Performance/BlockGivenWithExplicitBlock:
167
+ Enabled: true
168
+
169
+ Performance/CollectionLiteralInLoop:
170
+ Enabled: true
171
+
172
+ Performance/ConstantRegexp:
173
+ Enabled: true
174
+
175
+ Performance/MapCompact:
176
+ Enabled: true
177
+
178
+ Performance/MethodObjectAsBlock:
179
+ Enabled: true
180
+
181
+ Performance/RedundantEqualityComparisonBlock:
182
+ Enabled: true
183
+
184
+ Performance/RedundantSortBlock:
185
+ Enabled: true
186
+
187
+ Performance/RedundantSplitRegexpArgument:
188
+ Enabled: true
189
+
190
+ Performance/RedundantStringChars:
191
+ Enabled: true
192
+
193
+ Performance/ReverseFirst:
194
+ Enabled: true
195
+
196
+ Performance/SortReverse:
197
+ Enabled: true
198
+
199
+ Performance/Squeeze:
200
+ Enabled: true
201
+
202
+ Performance/StringInclude:
203
+ Enabled: true
204
+
205
+ Performance/Sum:
206
+ Enabled: true
207
+
208
+ Rails/ActiveRecordCallbacksOrder:
209
+ Enabled: true
210
+
211
+ Rails/AfterCommitOverride:
212
+ Enabled: true
213
+
214
+ Rails/AttributeDefaultBlockValue:
215
+ Enabled: true
216
+
217
+ Rails/DynamicFindBy:
218
+ Enabled: false
219
+
220
+ Rails/FindBy:
221
+ Enabled: false
222
+
223
+ Rails/FindById:
224
+ Enabled: true
225
+
226
+ Rails/HasManyOrHasOneDependent:
227
+ Enabled: false
228
+
229
+ Rails/Inquiry:
230
+ Enabled: true
231
+
232
+ Rails/InverseOf:
233
+ Enabled: false
234
+
235
+ Rails/MailerName:
236
+ Enabled: true
237
+
238
+ Rails/MatchRoute:
239
+ Enabled: true
240
+
241
+ Rails/NegateInclude:
242
+ Enabled: true
243
+
244
+ Rails/Pluck:
245
+ Enabled: true
246
+
247
+ Rails/OutputSafety:
248
+ Enabled: false
249
+
250
+ Rails/PluckInWhere:
251
+ Enabled: true
252
+
253
+ Rails/RenderInline:
254
+ Enabled: true
255
+
256
+ Rails/RenderPlainText:
257
+ Enabled: true
258
+
259
+ Rails/ShortI18n:
260
+ Enabled: true
261
+
262
+ Rails/SkipsModelValidations:
263
+ Enabled: false
264
+
265
+ Rails/SquishedSQLHeredocs:
266
+ Enabled: true
267
+
268
+ Rails/UnknownEnv:
269
+ Enabled: false
270
+
271
+ Rails/Validation:
272
+ Enabled: false
273
+
274
+ Rails/WhereEquals:
275
+ Enabled: true
276
+
277
+ Rails/WhereExists:
278
+ Enabled: true
279
+
280
+ Rails/WhereNot:
281
+ Enabled: true
282
+
283
+ RSpec/BeforeAfterAll:
284
+ Enabled: false
285
+
286
+ RSpec/ContextWording:
287
+ Enabled: false
288
+
289
+ RSpec/DescribedClass:
290
+ Enabled: false
291
+
292
+ RSpec/ExampleLength:
293
+ Max: 20
294
+
295
+ RSpec/Capybara:
296
+ Enabled: false
297
+
298
+ RSpec/ImplicitExpect:
299
+ Enabled: false
300
+
301
+ RSpec/ImplicitSubject:
302
+ Enabled: false
303
+
304
+ RSpec/InstanceVariable:
305
+ Enabled: false
306
+
307
+ RSpec/LeadingSubject:
308
+ Enabled: false
309
+
310
+ RSpec/MultipleExpectations:
311
+ Max: 10
312
+
313
+ RSpec/MultipleMemoizedHelpers:
314
+ Max: 8
315
+
316
+ RSpec/NestedGroups:
317
+ Max: 4
318
+
319
+ Style/ArgumentsForwarding:
320
+ Enabled: true
321
+
99
322
  Style/AsciiComments:
100
323
  Enabled: false
101
324
 
@@ -105,24 +328,63 @@ Style/BlockDelimiters:
105
328
  Style/ClassAndModuleChildren:
106
329
  Enabled: false
107
330
 
331
+ Style/CollectionCompact:
332
+ Enabled: true
333
+
108
334
  Style/ColonMethodCall:
109
335
  Enabled: false
110
336
 
111
337
  Style/CommandLiteral:
112
338
  Enabled: false
113
339
 
340
+ Style/Documentation:
341
+ Enabled: false
342
+
343
+ Style/DocumentDynamicEvalDefinition:
344
+ Enabled: true
345
+
114
346
  Style/DoubleNegation:
115
347
  Enabled: false
116
348
 
349
+ Style/EndlessMethod:
350
+ Enabled: true
351
+
117
352
  Style/GlobalVars:
118
353
  Enabled: false
119
354
 
355
+ Style/HashConversion:
356
+ Enabled: true
357
+
358
+ Style/HashEachMethods:
359
+ Enabled: true
360
+
361
+ Style/HashExcept:
362
+ Enabled: true
363
+
364
+ Style/HashTransformKeys:
365
+ Enabled: true
366
+
367
+ Style/HashTransformValues:
368
+ Enabled: true
369
+
370
+ Style/IfUnlessModifier:
371
+ Enabled: false
372
+
373
+ Style/IfWithBooleanLiteralBranches:
374
+ Enabled: true
375
+
120
376
  Style/Lambda:
121
377
  Enabled: false
122
378
 
123
379
  Style/MultilineIfModifier:
124
380
  Enabled: false
125
381
 
382
+ Style/NegatedIfElseCondition:
383
+ Enabled: true
384
+
385
+ Style/NilLambda:
386
+ Enabled: true
387
+
126
388
  Style/NumericPredicate:
127
389
  Enabled: false
128
390
 
@@ -130,6 +392,9 @@ Style/RedundantReturn:
130
392
  Enabled: false
131
393
  AllowMultipleReturnValues: true
132
394
 
395
+ Style/RedundantArgument:
396
+ Enabled: true
397
+
133
398
  Style/RedundantSelf:
134
399
  Enabled: false
135
400
 
@@ -139,5 +404,11 @@ Style/RegexpLiteral:
139
404
  Style/RescueModifier:
140
405
  Enabled: false
141
406
 
407
+ Style/StringChars:
408
+ Enabled: true
409
+
410
+ Style/SwapValues:
411
+ Enabled: true
412
+
142
413
  Style/SymbolArray:
143
414
  Enabled: false
data/.travis.yml CHANGED
@@ -1,7 +1,41 @@
1
1
  ---
2
- sudo: false
3
2
  language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.5.1
7
- before_install: gem install bundler -v 1.16.1
3
+
4
+ gemfile:
5
+ - Gemfile
6
+
7
+ before_install:
8
+ - gem update --system -N
9
+ - gem install bundler -N
10
+
11
+ services:
12
+ - redis
13
+
14
+ addons:
15
+ apt:
16
+ packages:
17
+ - chromium-browser
18
+
19
+ cache:
20
+ bundler: true
21
+ directories:
22
+ - ~/.webdrivers
23
+
24
+ notifications:
25
+ email:
26
+ on_success: never
27
+ on_failure: change
28
+
29
+ script: bundle exec rake $RAKE_TASK
30
+
31
+ matrix:
32
+ include:
33
+ - rvm: 2.7
34
+ gemfile: Gemfile
35
+ env: RAKE_TASK=spec
36
+ - rvm: 2.6
37
+ gemfile: Gemfile
38
+ env: RAKE_TASK=spec
39
+ - rvm: 2.5
40
+ gemfile: Gemfile
41
+ env: RAKE_TASK=spec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## 1.0.4
2
+
3
+ - Add option to populate seo cache for multi-domains
4
+
5
+ ## 1.0.3
6
+
7
+ - Ensure page rendered status is present after head element
8
+
9
+ ## 1.0.2
10
+
11
+ - Do not log missed cache for ignored statuses
12
+
13
+ ## 1.0.1
14
+
15
+ - Add user agent to missed caches
16
+
17
+ ## 1.0.0
18
+
19
+ - Update Readme (badges, syntax, links, ...)
20
+ - Add Travis CI
21
+ - Update dependencies
22
+ - Do not cache pages in error
23
+
1
24
  ## 0.19.0
2
25
 
3
26
  - Add option to cache page if user connected
data/CODE_OF_CONDUCT.md CHANGED
@@ -5,9 +5,9 @@
5
5
  In the interest of fostering an open and welcoming environment, we as
6
6
  contributors and maintainers pledge to making participation in our project and
7
7
  our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
11
 
12
12
  ## Our Standards
13
13
 
@@ -23,13 +23,13 @@ include:
23
23
  Examples of unacceptable behavior by participants include:
24
24
 
25
25
  * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
26
+ advances
27
27
  * Trolling, insulting/derogatory comments, and personal or political attacks
28
28
  * Public or private harassment
29
29
  * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
30
+ address, without explicit permission
31
31
  * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
32
+ professional setting
33
33
 
34
34
  ## Our Responsibilities
35
35
 
@@ -68,7 +68,9 @@ members of the project's leadership.
68
68
  ## Attribution
69
69
 
70
70
  This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
72
 
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
data/CONTRIBUTING.md CHANGED
@@ -1,41 +1,38 @@
1
- # Contributing
1
+ ## How to contribute to Ruby on Rails
2
2
 
3
- First, thanks for wanting to contribute. You’re awesome! :heart:
3
+ #### **Did you find a bug?**
4
4
 
5
- ## Help
5
+ * **Do not open up a GitHub issue if the bug is a security vulnerability**, and instead to contact us by email contact@ginkonote.com.
6
6
 
7
- We’re not able to provide support through GitHub Issues. If you’re looking for help with your code, try posting on [Stack Overflow](https://stackoverflow.com/).
7
+ * **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/floXcoder/seo_cache/issues).
8
8
 
9
- All features should be documented. If you don’t see a feature in the docs, assume it doesn’t exist.
9
+ * If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/floXcoder/seo_cache/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **scenario** demonstrating the expected behavior that is not occurring.
10
10
 
11
- ## Bugs
11
+ * If possible, use the relevant bug report templates to create the issue:
12
+ * [**Bug** issues](https://github.com/floXcoder/seo_cache/blob/develop/.github/ISSUE_TEMPLATE/bug_report.md)*
13
+
14
+ #### **Did you have an idea to improve the project?**
12
15
 
13
- Think you’ve discovered a bug?
16
+ * Open a new GitHub issue request with your idea.
14
17
 
15
- 1. Search existing issues to see if it’s been reported.
16
- 2. Try the `master` branch to make sure it hasn’t been fixed.
18
+ * If possible, use the relevant feature report templates to create the issue:
19
+ * [**Feature** issues](https://github.com/floXcoder/seo_cache/blob/develop/.github/ISSUE_TEMPLATE/feature_request.md)
17
20
 
18
- ```rb
19
- gem "seo_cache", github: "floXcode/seo_cache"
20
- ```
21
+ #### **Did you write a patch that fixes a bug or do you intend to add a new feature or change an existing one?**
21
22
 
22
- If the above steps don’t help, create an issue. Include:
23
+ * Fork the project, write your code and open a new GitHub pull request with the patch.
23
24
 
24
- - Detailed steps to reproduce
25
- - Complete backtraces for exceptions
25
+ * Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
26
26
 
27
- ## New Features
27
+ * If possible, use the relevant pull request report templates to create the issue:
28
+ * [**Pull Request**](https://github.com/floXcoder/seo_cache/blob/develop/.github/pull_request_template.md)
29
+
30
+ #### **Do you have questions about the source code?**
28
31
 
29
- If you’d like to discuss a new feature, create an issue and start the title with `[Idea]`.
32
+ * You can contact me by email: flo@l-x.fr. I will try to answer as much I can and if available.
30
33
 
31
- ## Pull Requests
32
34
 
33
- Fork the project and create a pull request. A few tips:
34
-
35
- - Keep changes to a minimum. If you have multiple features or fixes, submit multiple pull requests.
36
- - Follow the existing style. The code should read like it’s written by a single person.
37
-
38
- Feel free to open an issue to get feedback on your idea before spending too much time on it.
35
+ Thanks!
39
36
 
40
37
  ---
41
38
 
data/README.md CHANGED
@@ -1,14 +1,34 @@
1
1
  # SeoCache
2
2
 
3
- Cache dedicated for SEO with Javascript rendering :fire:
3
+ [![Gem Version](https://badge.fury.io/rb/seo_cache.svg)](https://badge.fury.io/rb/seo_cache)
4
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
5
+ [![Build Status](https://travis-ci.org/floXcoder/seo_cache.svg)](https://travis-ci.org/floXcoder/seo_cache)
6
+
7
+ **SeoCache is a dedicated cache for SEO with JavaScript rendering** :fire:
8
+
9
+ You can find in this article, a more detail explanation of the purpose and usage of this gem:
10
+
11
+ - In english: https://www.ginkonote.com/users/flo/articles/seo-generate-and-cache-your-pages@seo
12
+ - In french: https://www.ginkonote.com/fr/utilisateurs/flo/articles/seo-generation-et-mise-en-cache-des-pages@seo
13
+
14
+ ## Table of contents
15
+ - [Purpose](#purpose)
16
+ - [Installation](#installation)
17
+ - [Configuration](#configuration)
18
+ - [Helpers for controllers](#helpers-for-controllers)
19
+ - [Check cached pages](#check-cached-pages)
20
+ - [Automatic caching](#automatic-caching)
21
+ - [Server configuration](#server-configuration)
22
+ - [Inspiration](#inspiration)
23
+ - [Contributing](#contributing)
4
24
 
5
25
  ## Purpose
6
26
 
7
27
  Google credo is: Don't waste my bot time!
8
28
 
9
- So to reduce Googlebot crawling time, let's provide HTML files in a specific cache.
29
+ In order to reduce Googlebot crawling time, let's provide the complete HTML files in a specific cache.
10
30
 
11
- This cache is suitable for static (generated or not) pages but not for connected pages.
31
+ This cache is suitable for static (generated or not) pages but not for user private pages.
12
32
 
13
33
  ## Installation
14
34
 
@@ -38,7 +58,7 @@ require 'seo_cache'
38
58
  Rails.application.config.middleware.use SeoCache::Middleware
39
59
  ```
40
60
 
41
- ## Options
61
+ ## Configuration
42
62
 
43
63
  Chrome path (**required**) (`disk` or `memory`):
44
64
 
@@ -97,13 +117,13 @@ SeoCache.whitelist_hosts = []
97
117
  URLs to blacklist:
98
118
 
99
119
  ```ruby
100
- SeoCache.blacklist_params = %w[^/assets/.* ^/admin.*]
120
+ SeoCache.blacklist_urls = %w[^/assets/.* ^/admin.*]
101
121
  ```
102
122
 
103
123
  Params to blacklist:
104
124
 
105
125
  ```ruby
106
- SeoCache.blacklist_urls = %w[page]
126
+ SeoCache.blacklist_params = %w[page]
107
127
  ```
108
128
 
109
129
  URLs to whitelist:
@@ -154,28 +174,36 @@ If you encounter the following error `DevToolsActivePort file doesn't exist`, yo
154
174
  SeoCache.chrome_debugging_port = '9222'
155
175
  ```
156
176
 
157
- Be aware, JS will be rendered 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).
177
+ Be aware, JS will be rendered twice: once by this gem 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).
158
178
 
159
- 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.
179
+ Disk cache is recommended by default. Nginx will directly fetch HTML files on disk. The TTFB (time to first byte) will be under 200ms :). You can use memory cache if you have lot of RAM, but if you shut down your server, you will lost all the generated pages! So prefer cache disk storage.
160
180
 
161
- ## Controllers
181
+ ## Helpers for controllers
162
182
 
163
183
  You can check if seo mode is active in your controllers, with the following variable:
164
184
 
165
185
  ```ruby
166
- request.env['seo_mode']
186
+ def check_seo_mode
187
+ @seo_mode = (params.key?(SeoCache.prerender_url_param) || params.key?(SeoCache.force_cache_url_param))
188
+ end
167
189
  ```
168
190
 
191
+ And if you want to access to this variable in JS files:
192
+
193
+ ```javascript
194
+ window.seoMode = "{@seo_mode}"
195
+ ```
169
196
 
170
- ## Consult cache pages
171
197
 
172
- Too see in browser the cache page, open a browser and set the user agent to:
198
+ ## Check cached pages
199
+
200
+ Too see in browser the cached page, open a browser and set the user agent to:
173
201
 
174
202
  `Googlebot (Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html))`
175
203
 
176
- For instance, with Chrome or Chromium, you can change the user agent in "Network conditions" panel.
204
+ For instance, with Chrome or Chromium, you can change the user agent in "Network" / "Network conditions" panel.
177
205
 
178
- To (re)cache a page, add this parameter to the url (the browser must use the Googlebot user agent):
206
+ To (re)cache a page, add this parameter to the url (and the browser must use the Googlebot user agent):
179
207
 
180
208
  `/?_seo_cache_=true`
181
209
 
@@ -184,7 +212,7 @@ To (re)cache a page, add this parameter to the url (the browser must use the Goo
184
212
  To automate caching, create a cron rake task (e.g. in `lib/tasks/populate_seo_cache.rake`):
185
213
 
186
214
  ```ruby
187
- namespace :MyProject do
215
+ namespace :my_project do
188
216
 
189
217
  desc 'Populate cache for SEO'
190
218
  task populate_seo_cache: :environment do |_task, _args|
@@ -197,14 +225,16 @@ namespace :MyProject do
197
225
  end
198
226
  ```
199
227
 
200
- You can add the `force_cache: true` option to `SeoCache::PopulateCache` for overwrite cache data.
228
+ You can add the `force_cache: true` option to `SeoCache::PopulateCache` for overwrite cached data.
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.
201
231
 
202
- If you want to only 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 not called for pages not in cache.
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.
203
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.
204
234
 
205
- ## Server
235
+ ## Server configuration
206
236
 
207
- If you use disk caching, add to your Nginx configuration:
237
+ If you use disk caching, add this to your Nginx configuration:
208
238
 
209
239
  ```nginx
210
240
  # Before any block:
@@ -247,18 +277,29 @@ location / {
247
277
  rewrite ^/(.*)/$ /$1 last;
248
278
 
249
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;
250
282
  }
251
283
 
252
284
  location @rubyproxy {
253
- ...
285
+ proxy_connect_timeout 600;
286
+ proxy_send_timeout 600;
287
+ proxy_read_timeout 600;
288
+ send_timeout 600;
289
+ proxy_set_header Host $host;
290
+ proxy_set_header X-Real-IP $remote_addr;
291
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
292
+ proxy_set_header X-Forwarded-Proto $scheme;
293
+ proxy_pass_header Server;
294
+ proxy_pass http://0.0.0.0:3020;
254
295
  }
255
296
  ```
256
297
 
257
- This configuration allow you to use SEO cache only for bots (you can add other bots) and GET requests. For users, you don't want to use the cached page (user connection, basket, ...). The performance are less important for users then bots.
298
+ This configuration allow you to use SEO cache only for bots (you can add other bots at the beginning of the file) and HTML GET requests. For connected users, you don't want to use the cached page (user connection, basket, ...). The performance are less important for users than bots.
258
299
 
259
300
  ## Heroku case
260
301
 
261
- If you use Heroku server, you can't store file on dynos. But you have two alternatives :
302
+ If you use Heroku server, you can't store files on dynos. But you have two alternatives:
262
303
 
263
304
  - Use the memory mode
264
305
 
@@ -21,7 +21,10 @@ module SeoCache
21
21
 
22
22
  return cached_response.finish if cached_response.present?
23
23
 
24
- SeoCache.log('missed cache : ' + Rack::Request.new(env).path) if SeoCache.log_missed_cache
24
+ if SeoCache.log_missed_cache
25
+ env_request = Rack::Request.new(env)
26
+ SeoCache.log("missed cache : #{env_request.path} (User agent: #{env_request.user_agent})")
27
+ end
25
28
 
26
29
  if SeoCache.prerender_service_url.present?
27
30
  prerender_response = prerender_service(env)
@@ -33,8 +36,8 @@ module SeoCache
33
36
  else
34
37
  Thread.new do
35
38
  prerender_data = page_render(env)
36
- # Extract status from render page (return 500 if status cannot be found, some problems happen somewhere)
37
- status = prerender_data&.scan(/<!--status:(\d+)-->/)&.last&.first || 500
39
+ # Extract status from render page or return 404
40
+ status = prerender_data&.scan(/<!--status:(\d+)-->/)&.last&.first
38
41
  after_render(env, prerender_data, status || 200)
39
42
  end
40
43
  end
@@ -45,7 +48,7 @@ module SeoCache
45
48
  status_code = "<!--status:#{status}-->"
46
49
  # Cannot add at the top of file, Chrome removes leading comments...
47
50
  begin
48
- body_code = response.body.sub('<head>', "<head>#{status_code}")
51
+ body_code = response.body.sub(/<head( ?)(.*?)>/i, "<head\\1\\2>#{status_code}")
49
52
  return [status, headers, [body_code]]
50
53
  rescue
51
54
  return [status, headers, [nil]]
@@ -204,6 +207,11 @@ module SeoCache
204
207
  def after_render(env, response, status = 200)
205
208
  return unless response && SeoCache.cache_only_status.include?(status.to_i)
206
209
 
210
+ if SeoCache.log_missed_cache
211
+ env_request = Rack::Request.new(env)
212
+ SeoCache.log("missed cache : #{env_request.path} (User agent: #{env_request.user_agent})")
213
+ end
214
+
207
215
  @page_caching.cache(response, Rack::Request.new(env).path)
208
216
  end
209
217
  end
@@ -14,6 +14,8 @@ module SeoCache
14
14
  return @driver.page_source
15
15
  rescue StandardError => error
16
16
  SeoCache.log_error(error.message)
17
+
18
+ return false
17
19
  ensure
18
20
  @driver&.quit if quit_after_render
19
21
  end
@@ -11,27 +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 += if path.include?('?')
23
- '&'
24
- else
25
- '?'
26
- end
27
- url += "#{SeoCache.prerender_url_param}=true"
28
-
29
- page_source = @page_render.get(url, false)
30
- @page_caching.cache(page_source, path)
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
31
29
  end
32
30
 
33
31
  ensure
34
32
  @page_render.close_connection
35
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
36
50
  end
37
51
  end
@@ -1,3 +1,3 @@
1
1
  module SeoCache
2
- VERSION = '0.19.0'.freeze
2
+ VERSION = '1.0.4'.freeze
3
3
  end
data/seo_cache.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency 'selenium-webdriver', '~> 3'
29
29
  spec.add_dependency 'webdrivers', '~> 4'
30
30
 
31
- spec.add_development_dependency 'bundler', '~> 1'
31
+ spec.add_development_dependency 'bundler', '~> 2'
32
32
  spec.add_development_dependency 'rake', '~> 13'
33
33
  spec.add_development_dependency 'rspec', '~> 3'
34
34
  spec.add_development_dependency 'simplecov', '~> 0.17'
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.19.0
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: 2020-05-11 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
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1'
117
+ version: '2'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1'
124
+ version: '2'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rake
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -186,6 +186,9 @@ executables: []
186
186
  extensions: []
187
187
  extra_rdoc_files: []
188
188
  files:
189
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
190
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
191
+ - ".github/pull_request_template.md"
189
192
  - ".gitignore"
190
193
  - ".rspec"
191
194
  - ".rubocop.yml"
@@ -226,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
229
  - !ruby/object:Gem::Version
227
230
  version: '0'
228
231
  requirements: []
229
- rubygems_version: 3.1.3
232
+ rubygems_version: 3.2.17
230
233
  signing_key:
231
234
  specification_version: 4
232
235
  summary: Cache dedicated for SEO with Javascript rendering