Commit Graph

44 Commits (167a8b5e9421e0ab51fbf44c5621632f4a1a90c5)

Author SHA1 Message Date
leonklingele 167a8b5e94
🚀 Feature: Add and apply more stricter golangci-lint linting rules (#2286)
* golangci-lint: add and apply more stricter linting rules

* github: drop security workflow now that we use gosec linter inside golangci-lint

* github: use official golangci-lint CI linter

* Add editorconfig and gitattributes file
2023-01-27 09:01:37 +01:00
M. Efe Çetin 691d2e6ad5
🗑️ deprecate: go 1.14 & go 1.15 support deprecation (#2172)
* 🗑️ deprecate: go 1.14 & go 1.15 support deprecation
https://github.com/valyala/fasthttp/pull/1379

* fix tests
2022-10-26 11:51:50 +02:00
marcmartin13 c187c6a2f5
🚀 [Feature]: Cache-Control: no-cache (#2159)
* Added noCache field

Check if the request header Cache-Control contains no-cache

* Update cache.go

* Update config.go

* Update cache.go

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1

* patch-1
2022-10-21 10:28:31 +02:00
M. Efe Çetin 8ec62a64cc
🧹 update: add methods configuration for cache middleware (#2081)
* 🧹 update: add methods configuration for cache middleware

* 🧹 update: add methods configuration for cache middleware
2022-09-11 13:11:33 +02:00
Amir Hossein ffb2d4cb1a
fix unhandled error in cache package tests (#2049)
* fix unhandled errors

* fix unhandled error in cache package test

* omit variable type

* omit variable type

* rename variable because collide with the imported package name
2022-08-26 14:10:46 +02:00
Vladislav aa229287cf
🔥 Feature: Add max size to cache (#1892)
* Cache middleware size limit

* Replace MaxInt with MaxInt32. Add comments to benchmark

* Avoid allocation in heap push. Small fixes

* Count body sizes instead of entries

* Update cache/readme
2022-05-10 08:50:26 +02:00
Pinank Solanki bb9ac8feaf
🐛 Fix expiration time in cache middleware (#1881)
* 🐛 Fix: Expiration time in cache middleware

* Custom expiration time using ExpirationGenerator is also functional
now instead of default Expiration only

* 🚨 Improve Test_CustomExpiration

* - stabilization of the tests
- speed up the cache tests
- fix race conditions in client and client tests

Co-authored-by: wernerr <rene@gofiber.io>
2022-05-01 11:43:46 +02:00
akp e974c6793f
RFC: Return an instance of `*fiber.Error` when no handler found (#1847)
* Return an instance of `*fiber.Error` when no handler found

When a handler cannot be found for a given path, previously Fiber
would construct a plaintext response that cannot be modified.

This commit switches to returning a new instance of `*fiber.Error`
with identical error message so that users can customise the look
of their 404 pages.

Signed-off-by: AKP <tom@tdpain.net>

* Fix `Test_App_Next_Method`

This test was failing as the error returned by `c.Next()` that's
required to generate the correct 404 status code was not being
passed through the middleware and being silently ignored.

Signed-off-by: AKP <tom@tdpain.net>

* Fix `Test_Logger_All`

Signed-off-by: AKP <tom@tdpain.net>

* Fix `Test_Cache_WithHeadThenGet` test

As far as I can tell, this test is meant to check that a cached
HEAD request to a given endpoint does not return the cached
content to a GET request to the same endpoint, and the test has
been altered to correctly check for this.

Signed-off-by: AKP <tom@tdpain.net>
2022-04-05 08:39:53 +02:00
Théotime Lévêque 1cddc56f13
Cache middleware: Store e2e headers. (#1807)
*  Cache middleware: Store e2e headers.

As defined in RFC2616 - section-13.5.1, shared caches MUST
store end-to-end headers from backend response and MUST be
transmitted in any response formed from a cache entry.

This commit ensures a stronger consistency between responses
served from the handlers & from the cache middleware.

*  Cache middleware: Add flag for e2e headers.

Set flag to prevent e2e headers caching to
be the default behavior of the cache middleware.
This would otherwise change quite a lot the
experience for cache middleware current users.

*  Cache middleware: Add Benchmark for additionalHeaders feature.

*  Cache middleware: Rename E2Eheaders into StoreResponseHeaders.

E2E is an acronym commonly associated with test.
While in the present case it refers to end-to-end
HTTP headers (by opposition to hop-by-hop), this
still remains confusing. This commits renames it
to a more generic name.

*  Cache middleware: Update README

*  Cache middleware: Move map instanciation.

This will prevent an extra memory allocation for users
not interested in this feature.

*  Cache middleware: Prevent memory allocation when StoreResponseHeaders is disabled.

*  Cache middleware: Store e2e headers. #1807
- use set instead of add for the headers
- copy value from the headers -> prevent problems with mutable values

Co-authored-by: wernerr <rene@gofiber.io>
2022-03-08 10:18:04 +01:00
liaohongxing 1fd6eabba9
fix cache docs error (#1769) 2022-02-12 13:00:00 +01:00
Jesse Quinn d411ec10d6
added HEAD method to caching (#1730)
* added HEAD method to caching

* changed key due to head and get sharing same key

* Update cache.go

- add a improvement task for later

* Update cache.go

correct comment

Co-authored-by: Jesse Quinn <jesse.quinn@zpesystems.com>
Co-authored-by: RW <rene@gofiber.io>
2022-01-24 16:36:46 +01:00
djunny f9d5f787af
Feature: [Cache] add ExpirationGenerator for generate custom Expiration (#1618)
* Feature: [Cache] add ExpirationGenerator for generate custom Expiration

* fix: add document and code snippet for README

Co-authored-by: dj <github@djunny.com>
2021-11-11 11:30:38 +01:00
Gusted 7b7dcf29f7
♻️ Tidy up the codebase (#1613)
* run gofmt

* add t.Helper()

* Simplify assigns

* Simplify make operation

* Remove unused field in struct

* Fix typo

* Run gofumpt ./

* Consistent spacing

* len(...) can never be negative

* Use ReplaceAll

* Simplify operation

* Remove deadcode

* Fix typo

* Tidy up `} else { if ...`

* Fix AssertEqual

* Remove t.Helper() to fix go1.14.15
2021-11-05 08:00:03 +01:00
RW 2272e4a6b1
🐛 Get unexpected results from cache #1529 (#1531) 2021-09-15 14:20:43 +02:00
RW d777d889bb
Fix cache expired test (#1461)
* Improve/Stabilize the "Test_Cache_Expired" test run
2021-07-30 20:19:18 +02:00
Javad Rajabzade 7609117cec
Improved some conditions (#1386)
* simplify `u <= (1<<7)-1` to `u < (1 << 7)`

* It's not recommended to use `len` for empty string, we can check with string with ""

* It's not recommended to use `len` for empty string, we can check with string with ""

* It's not recommended to use `len` for empty string, we can check with string with ""

* It's not recommended to use `len` for empty string, we can check with string with ""

* Instead Bool comparison can using simplified bool check if !var = false checking

* Unnecessary use of fmt.Sprintf for value without format

* For check condition two value not required ! method

* nil check may not be enough for slice, better check with len

* function parameters combined

* When the form returns error information, the text content should not start with a capital letter or end with a punctuation mark

* error var invalidPath should have name of the form errFoo, It is recommended that the error variables that are part of an API should be named

* change to condition len(x), it's faster https://github.com/gofiber/fiber/pull/1386#discussion_r652369520

* Update write.go

* Update write_bytes.go

* Update store.go

Co-authored-by: RW <rene@gofiber.io>
2021-06-17 22:03:59 +02:00
Wei Lun bca01cc9cc
🔥 Feature: add cache header to show cache status (#1368)
* add cache header to show cache status

* update default CacheHeader to X-Cache

* add CacheHeader test

* Update cache_test.go

use constants in test

Co-authored-by: RW <rene@gofiber.io>
2021-06-13 10:52:03 +02:00
Ivan Sotnikov d9c13d3442
🐛 Set expiration time in test to 1.5 due to the timer error (#1229) 2021-03-19 19:10:53 +01:00
Ivan Sotnikov b517de85ec
🐛 update expiration for expired entry (#1228) 2021-03-17 08:08:44 +01:00
tianjipeng 08a2e7a82d ajust cache middleware config.Next position 2021-01-26 10:26:13 +08:00
Fenny 323d9d89cc 🩹 fix manager logic 2020-11-23 07:38:42 +01:00
Fenny 8fe458011d 📦 add mapstore 2020-11-20 11:43:07 +01:00
Fenny bb3a7fe5da 🩹 fix cache
Co-Authored-By: RW <7063188+ReneWerner87@users.noreply.github.com>
2020-11-17 08:33:07 +01:00
Fenny a9d628641e 🍌 increase sleep for workflow 2020-11-06 02:29:31 +01:00
Fenny f02b8d8317 Merge remote-tracking branch 'upstream/master' 2020-11-06 02:28:39 +01:00
Fenny 0d3d6d9fe8 📦 update fasthttp and storage interface 2020-11-06 01:52:05 +01:00
Jay Chung 0146b92ba6 refactor: clean up 2020-11-04 23:17:00 +08:00
Joey 5d6e62b7c1
Merge pull request #984 from Fenny/master
✏ update Storage behaviour
2020-10-30 23:55:56 -07:00
Fenny 7892ab62bf 📦 update Storage behaviour 2020-10-31 07:51:44 +01:00
Tom 1ad625704d
📦 Add Key option to Cache config (#983) 2020-10-31 01:19:33 +00:00
Fenny 7ca70fcb17 🔍 verify body length
Co-Authored-By: kiyon <kiyon@gofiber.io>
2020-10-29 06:54:41 +01:00
Fenny f5314b66b9 📈 update benchmark
Co-Authored-By: kiyon <kiyon@gofiber.io>
2020-10-29 06:50:09 +01:00
Fenny 70d7c53557 🩹 fix race condition 2020-10-29 06:38:41 +01:00
Fenny 79c151c238 🚀 improve Store in cache mw 2020-10-29 06:32:09 +01:00
Fenny ecdda95e15 💼 implement Storage 2020-10-28 02:29:47 +01:00
Fenny 33e91e8111 📦 add benchmark 2020-10-08 18:11:26 +02:00
Fenny b37789836d 🧪 update cache test 2020-10-06 20:15:21 +02:00
Konstantinos Lypitkas 9df61e925c Increase coverage in cache middleware 2020-10-04 10:41:54 +03:00
Fenny 81208a6d6a 📦fix tests
Co-Authored-By: Tom <tom@tdpain.net>
2020-10-01 19:49:49 +02:00
Fenny 55960e86c3 📦 add cache-control option
Co-Authored-By: Tom <tom@tdpain.net>
2020-10-01 19:37:34 +02:00
Fenny 7bb6081371 📦 fix race condition in cache mw
Co-Authored-By: Konstantinos Lypitkas <3259834+klipitkas@users.noreply.github.com>
Co-Authored-By: kiyon <kiyon@gofiber.io>
2020-10-01 16:53:27 +02:00
Konstantinos Lypitkas 9a650b8d2a Fix issue with expiration, increase coverage 2020-10-01 00:21:30 +03:00
Konstantinos Lypitkas f921efe05a Add basic test for cache middleware 2020-09-30 23:34:31 +03:00
Fenny 2ec4f7d0da 📦 introduce cache mw
Co-Authored-By: Tom <tom@tdpain.net>
2020-09-26 11:13:11 +02:00