seo_cache 0.18.0 → 1.0.3

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: 6132fa1fc97736b7bbfea3971ae247d65dd7a373a799ce4907bbd2106f8f9fa6
4
- data.tar.gz: 067f4bdea04af6f7c931c2ce09f283fb907c6a7a56afe364ef5ea932e320f3b1
3
+ metadata.gz: f2c6084cfed22c86d8dae948445d042fb5bcccd8a01afac54974dfaa96181f20
4
+ data.tar.gz: a71c76d0d492bb9058d68a81ae8c5aa3170ef09d64192818d6f3a573453f18c9
5
5
  SHA512:
6
- metadata.gz: e4826755941dc1bfba9f98182c5d3c07d2ca78fe62f443b9e432c3411fc232099ca7966a97191a8e1fa6630b5551fca4679f9c47781411b1e4182f2013093d19
7
- data.tar.gz: 6aa1029ab15d5f6abd879cb54fe5cb74f972aa452c4555ee19dd4ac98cb63459507d742b2e359ad627eb593b940efc0a59c68435ee72780b3e520e2d46fc1c3f
6
+ metadata.gz: 454155f0bcc296c6ccd1d7d3eafa90d5a83f17a38c1d24cdd4d52a7ae44eb2dca7dc493fad4233c30b33fb6183028a39bb7e8c60baa55a61533b22ac239267fd
7
+ data.tar.gz: cf60d5d45b01fc2de32ee0963bd086e48859adcc6abcfee8921dcade7a38bdaae09727dfa025a49c0116f36fcff76f6adb651000293f6514db13d2415ccb223c
@@ -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.3
2
+
3
+ - Ensure page rendered status is present after head element
4
+
5
+ ## 1.0.2
6
+
7
+ - Do not log missed cache for ignored statuses
8
+
9
+ ## 1.0.1
10
+
11
+ - Add user agent to missed caches
12
+
13
+ ## 1.0.0
14
+
15
+ - Update Readme (badges, syntax, links, ...)
16
+ - Add Travis CI
17
+ - Update dependencies
18
+ - Do not cache pages in error
19
+
20
+ ## 0.19.0
21
+
22
+ - Add option to cache page if user connected
23
+
1
24
  ## 0.18.0
2
25
 
3
26
  - Correct use of prerender param in URL
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:
@@ -112,6 +132,12 @@ URLs to whitelist:
112
132
  SeoCache.whitelist_urls = []
113
133
  ```
114
134
 
135
+ Cache page even if user is connected (be careful when caching sensitive data):
136
+
137
+ ```ruby
138
+ SeoCache.cache_with_user_connected = true
139
+ ```
140
+
115
141
  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`):
116
142
 
117
143
  ```ruby
@@ -148,28 +174,36 @@ If you encounter the following error `DevToolsActivePort file doesn't exist`, yo
148
174
  SeoCache.chrome_debugging_port = '9222'
149
175
  ```
150
176
 
151
- 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).
152
178
 
153
- 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.
154
180
 
155
- ## Controllers
181
+ ## Helpers for controllers
156
182
 
157
183
  You can check if seo mode is active in your controllers, with the following variable:
158
184
 
159
185
  ```ruby
160
- 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
189
+ ```
190
+
191
+ And if you want to access to this variable in JS files:
192
+
193
+ ```javascript
194
+ window.seoMode = "{@seo_mode}"
161
195
  ```
162
196
 
163
197
 
164
- ## Consult cache pages
198
+ ## Check cached pages
165
199
 
166
- Too see in browser the cache page, open a browser and set the user agent to:
200
+ Too see in browser the cached page, open a browser and set the user agent to:
167
201
 
168
202
  `Googlebot (Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html))`
169
203
 
170
- 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.
171
205
 
172
- 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):
173
207
 
174
208
  `/?_seo_cache_=true`
175
209
 
@@ -178,7 +212,7 @@ To (re)cache a page, add this parameter to the url (the browser must use the Goo
178
212
  To automate caching, create a cron rake task (e.g. in `lib/tasks/populate_seo_cache.rake`):
179
213
 
180
214
  ```ruby
181
- namespace :MyProject do
215
+ namespace :my_project do
182
216
 
183
217
  desc 'Populate cache for SEO'
184
218
  task populate_seo_cache: :environment do |_task, _args|
@@ -191,14 +225,14 @@ namespace :MyProject do
191
225
  end
192
226
  ```
193
227
 
194
- 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.
195
229
 
196
- 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.
230
+ 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.
197
231
  It's useful if you have a script which generates all website pages (based on sitemap for instance) and you run script every day.
198
232
 
199
- ## Server
233
+ ## Server configuration
200
234
 
201
- If you use disk caching, add to your Nginx configuration:
235
+ If you use disk caching, add this to your Nginx configuration:
202
236
 
203
237
  ```nginx
204
238
  # Before any block:
@@ -236,20 +270,32 @@ location / {
236
270
  if ($arg__seo_cache_) {
237
271
  break;
238
272
  }
273
+
274
+ # Local rewrite to remove trailing slash
275
+ rewrite ^/(.*)/$ /$1 last;
239
276
 
240
277
  try_files /seo_cache/$uri/index$cache_extension /seo_cache/$uri$cache_extension /seo_cache/$uri $uri @rubyproxy;
241
278
  }
242
279
 
243
280
  location @rubyproxy {
244
- ...
281
+ proxy_connect_timeout 600;
282
+ proxy_send_timeout 600;
283
+ proxy_read_timeout 600;
284
+ send_timeout 600;
285
+ proxy_set_header Host $host;
286
+ proxy_set_header X-Real-IP $remote_addr;
287
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
288
+ proxy_set_header X-Forwarded-Proto $scheme;
289
+ proxy_pass_header Server;
290
+ proxy_pass http://0.0.0.0:3020;
245
291
  }
246
292
  ```
247
293
 
248
- 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.
294
+ 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.
249
295
 
250
296
  ## Heroku case
251
297
 
252
- If you use Heroku server, you can't store file on dynos. But you have two alternatives :
298
+ If you use Heroku server, you can't store files on dynos. But you have two alternatives:
253
299
 
254
300
  - Use the memory mode
255
301
 
data/lib/seo_cache.rb CHANGED
@@ -43,6 +43,9 @@ module SeoCache
43
43
  mattr_accessor :blacklist_params
44
44
  self.blacklist_params = []
45
45
 
46
+ mattr_accessor :cache_with_user_connected
47
+ self.cache_with_user_connected = false
48
+
46
49
  mattr_accessor :log_missed_cache
47
50
  self.log_missed_cache = false
48
51
 
@@ -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]]
@@ -78,6 +81,9 @@ module SeoCache
78
81
  request = Rack::Request.new(env)
79
82
  query_params = Rack::Utils.parse_query(request.query_string)
80
83
 
84
+ # Check if user connected
85
+ return false if !SeoCache.cache_with_user_connected && (env['warden'].respond_to?(:user) && env['warden'].user.present?)
86
+
81
87
  # If it is the generated page...don't prerender
82
88
  return false if query_params.has_key?(SeoCache.prerender_url_param)
83
89
 
@@ -201,6 +207,11 @@ module SeoCache
201
207
  def after_render(env, response, status = 200)
202
208
  return unless response && SeoCache.cache_only_status.include?(status.to_i)
203
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
+
204
215
  @page_caching.cache(response, Rack::Request.new(env).path)
205
216
  end
206
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
@@ -6,9 +6,9 @@ require 'seo_cache/page_render'
6
6
  module SeoCache
7
7
  class PopulateCache
8
8
  def initialize(host, paths, options = {})
9
- @host = host
10
- @paths = paths
11
- @page_render = PageRender.new
9
+ @host = host
10
+ @paths = paths
11
+ @page_render = PageRender.new
12
12
  @page_caching = PageCaching.new
13
13
 
14
14
  @force_cache = options.fetch(:force_cache, false)
@@ -19,17 +19,14 @@ module SeoCache
19
19
  next if @page_caching.cache_exists?(path) && !@force_cache
20
20
 
21
21
  url = @host + path
22
- url += if path.include?('?')
23
- '&'
24
- else
25
- '?'
26
- end
22
+ url += path.include?('?') ? '&' : '?'
27
23
  url += "#{SeoCache.prerender_url_param}=true"
28
24
 
29
25
  page_source = @page_render.get(url, false)
30
- @page_caching.cache(page_source, path)
26
+ @page_caching.cache(page_source, path) if page_source
31
27
  end
32
28
 
29
+ ensure
33
30
  @page_render.close_connection
34
31
  end
35
32
  end
@@ -1,3 +1,3 @@
1
1
  module SeoCache
2
- VERSION = '0.18.0'.freeze
2
+ VERSION = '1.0.3'.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.18.0
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - FloXcoder
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-20 00:00:00.000000000 Z
11
+ date: 2021-05-01 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.2
232
+ rubygems_version: 3.2.16
230
233
  signing_key:
231
234
  specification_version: 4
232
235
  summary: Cache dedicated for SEO with Javascript rendering