Commit Graph

66 Commits (0bf0353a13173d6bc089100b673cd0162ad3b879)

Author SHA1 Message Date
Kashiwa ef4effc8a0
♻️ Refactor: Reduce the Memory Usage of ignoreHeaders (#3322)
♻️ Refactor: reduce the memory usage of ignoreHeaders

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
2025-02-24 08:12:47 +01:00
miyamo2 8970f515dd
🐛 fix: Align cache middleware with RFC7231 (#3283)
* 🩹 Fix(v3;middleware/cache): don't cache if status code is not cacheable

* allow 418 TeaPot

* fix test

* fix lint error

* check cacheability with map

* documentation

* fix: markdown lint

---------

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
2025-01-20 08:22:51 +01:00
miyamo2 0caa103a43
chore(middleware/cache): fix typo (#3145) 2024-09-25 08:44:04 +02:00
Juan Calderon-Perez 0ef8d716ee
Bump golangci-lint to v1.61.0 (#3135)
* Bump golangci-lint to v1.61.0

* Fix golangci warnings
2024-09-15 19:28:22 +02:00
Bruno f413bfef99
🐛 [Bug]: cache middleware: runtime error: index out of range [0] with length 0 (#3075)
Resolves #3072

Signed-off-by: brunodmartins <bdm2943@icloud.com>
2024-07-23 08:36:41 +02:00
Can Celik c9b7b1aefb
🔥 Add Cache Invalidation Option to Cache Middleware (#3036)
* Add an option to invalidate cache

* Add a summary about the cache middleware update

* Rename the option to make it clearer

* Rename hard tab

* Fix markdown formatting

* Revert unnecessary change

* Clarify the description of cache invalidator

* Add empty line

---------

Co-authored-by: RW <rene@gofiber.io>
2024-06-26 16:02:48 +02:00
Orville Simba 23bcbd3324
🩹 Fix: Optimize Cache middleware handler (#3031)
* Optimize cache handler

* revert to cfg.KeyGenerator(c) + _ + requestMethod

---------

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
2024-06-12 16:22:36 +02:00
Muhammed Efe Cetin 6ea4d81331
Merge branch 'master' into v3-beta 2023-11-07 20:22:31 +03:00
Eng Zer Jun 242ff94505
♻️ Refactor: Remove redundant nil check (#2584)
From the Go docs:

  "If the map is nil, the number of iterations is 0." [1]

Therefore, an additional nil check for before the loop is unnecessary.

[1]: https://go.dev/ref/spec#For_range

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2023-08-17 20:49:53 +02:00
Muhammed Efe Çetin 088cde594d
Merge remote-tracking branch 'origin/master' into v3-beta 2023-02-05 23:43:42 +03:00
leonklingele ac4ce21d9c
🐛 Bug: Fix issues introduced in linting PR (#2319)
* internal: revert linting changes

Changes to the internal package should not have been made in 167a8b5e94.

* middleware/monitor: revert changes to exported field "ChartJSURL"

This is a breaking change introduced in 167a8b5e94.

* middleware/monitor: fix error checking

Fix the errorenous error checking introduced in 167a8b5e94.

* 🐛 Bug: Fix issues introduced in linting PR #2319

* 🐛 Bug: Fix issues introduced in linting PR #2319

* Bug: Fix issues introduced in linting PR #2319

---------

Co-authored-by: René Werner <rene@gofiber.io>
2023-02-02 15:57:40 +01:00
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
leonklingele 802defa5ff
v3 (chore): cleanup (#2255)
* middleware: switch to new Ctx interface in documentation

* all: use any instead of interface{}
2022-12-03 15:39:57 +03:00
Kris Carr f26d9b1d4e
v3 (deps): update to use gofiber/utils/v2 (#2184) 2022-10-31 16:44:53 +03:00
Muhammed Efe Çetin 9428befb9c
Merge remote-tracking branch 'origin/master' into v3-beta 2022-10-28 17:26:17 +03: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
Muhammed Efe Çetin ca6f25a890
v3 (deps): move `utils` to `https://github.com/gofiber/utils` 2022-09-23 21:19:44 +03: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
Muhammed Efe Çetin 78c6197430
♻️ v3 (enhancement): remove automatic HEAD method creation from Get()
ref: https://github.com/gofiber/fiber/issues/2026
2022-09-05 17:41:39 +03:00
M. Efe Çetin a458bd344c
v3 (feature): convert fiber.Ctx type to interface (#1928)
*  v3: convert fiber.Ctx type to interface

* update ctx methods

* add new methods to customize ctx, fix some problems

* update comments.

* fix something
2022-07-13 07:48:29 +02:00
Muhammed Efe Çetin c7f45ec38e
v3: replace interface{}s by any 2022-05-31 17:41:38 +03:00
Muhammed Efe Çetin 1188144d78
🎉 v3: init 2022-05-31 17:35:49 +03: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
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
apoq b9efc76722
Fix cache mutex lock (#1764) 2022-02-11 09:48:52 +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
Michael Weiss 743d8ec08c
Fix comment (#1597)
When merging #1310, the corresponding adaptation of a code comment appears to have gone forgotten.
2021-10-25 18:37:50 +02:00
Kazumasa Takenaka (Bamboo) f5338266e3
fix typo (#1442)
paramters -> parameters
avilable  -> available
seperated -> separated
2021-07-17 17:20:14 +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 15cb3dc025
🐛 Cache Middleware - Race condition in the cache expiration logic. Round 2 (#1310)
* 🐛 fix: decrease watchdog period time
2021-05-04 09:18:48 +02:00
Roman ca0e784fb9
Refactor cache middleware to not-use the deprecated methods (#1246)
* ♻️ refactor: cache: don't use the deprecated `SafeBytes` and use `CopyBytes` instead

* ♻️ refactor: utils: remove deprecated and unused methods
2021-03-30 23:31: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 142e6e53be 🩹 fix #1055 2020-12-06 16:43:24 +01: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 9d5b58d210 🩹 remove mutex
Co-Authored-By: RW <7063188+ReneWerner87@users.noreply.github.com>
2020-11-17 13:06:59 +01:00
Fenny a2f54222bb 🩹 remove return nil
Co-Authored-By: RW <7063188+ReneWerner87@users.noreply.github.com>
2020-11-17 13:05:17 +01:00
Fenny 9be8eedcc6 🩹 fix cache mw
Co-Authored-By: RW <7063188+ReneWerner87@users.noreply.github.com>
2020-11-17 13:03:18 +01:00
Fenny 56cf415a0a simplify storage handler
Co-Authored-By: RW <7063188+ReneWerner87@users.noreply.github.com>
2020-11-17 10:40:11 +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 8bd50de610 🧹 housekeeping 2020-11-11 13:54:27 +01: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 cee3c759e3 🦺 copy cType in cache mw
Co-Authored-By: kiyon <kiyon@gofiber.io>
2020-10-29 06:43:59 +01:00
Fenny 5bc5f96324 🦺 make copy of body 2020-10-29 06:41:05 +01:00