Skip to content

feature: support for proxy caching plugin based on disk.#1153

Merged
membphis merged 22 commits into
apache:masterfrom
agile6v:dev
Mar 15, 2020
Merged

feature: support for proxy caching plugin based on disk.#1153
membphis merged 22 commits into
apache:masterfrom
agile6v:dev

Conversation

@agile6v

@agile6v agile6v commented Feb 23, 2020

Copy link
Copy Markdown
Member

Summary

This is a prototype implementation and there is a lot of work to be done.

Hopefully it does not affect the review. Thanks.

The admin api looks like the following:

{
    "plugins": {
        "proxy-cache": {
           "cache_zone": "disk_cache_one",
           "cache_key": "${uri}-cache-key",
           "cache_bypass": "${arg_bypass}",
           "cache_method": ["GET"],
           "cache_http_status": [200],
           "hide_cache_headers": true,
           "no_cache": "$arg_no_cache"
        }
    },
    "upstream": {
        "nodes": {
            "127.0.0.1:1999": 1
        },
        "type": "roundrobin"
    },
    "uri": "/hello"
}

Fix #1127

@agile6v

agile6v commented Feb 23, 2020

Copy link
Copy Markdown
Member Author

Currently only supports the upstream dynamically specify the cache time. If the upstream does not specify it such as the header Expires or Cache-Control, the cache_ttl in the config.yaml will be used. And the option hide_cache_headers will be decide whether the upstream header Expires and Cache-Control is sent to the client.
It's just a trick. Hopefully it can be easily understand.
Thanks.

Comment thread lua/apisix/plugins/proxy-cache.lua Outdated
@moonming

Copy link
Copy Markdown
Member

how to add test cases for this plugin?

@agile6v

agile6v commented Feb 26, 2020

Copy link
Copy Markdown
Member Author

Hi @moonming

Tests cases I think the t/servroot/conf/nginx.conf file should be modified.

In recent days, i have been preparing to make a presentation. So I'm gonna add tests in this weekend.
And are there any other problems with code implementation?
Thanks.

Comment thread lua/apisix/plugins/proxy-cache.lua Outdated
Comment thread lua/apisix/plugins/proxy-cache.lua Outdated
Comment thread lua/apisix/plugins/proxy-cache.lua Outdated
Comment thread lua/apisix/plugins/proxy-cache.lua Outdated
Comment thread lua/apisix/plugins/proxy-cache.lua
Comment thread lua/apisix/plugins/proxy-cache.lua Outdated
Comment thread conf/config.yaml Outdated
Comment thread conf/config.yaml Outdated
Comment thread lua/apisix/plugins/proxy-cache.lua Outdated
Comment thread lua/apisix/plugins/proxy-cache.lua Outdated
Comment thread bin/apisix Outdated
@membphis

membphis commented Mar 2, 2020

Copy link
Copy Markdown
Member

How about the new style? I think the new style is simpler.

# current style
"proxy-cache": {
    "cache_key": ["$uri"]
    "cache_bypass": ["$arg_bypass"],
    ... ...
}
# new style
"proxy-cache": {
    "cache_key": ["uri"]
    "cache_bypass": ["arg_bypass"],
    ... ...
}

@membphis

membphis commented Mar 2, 2020

Copy link
Copy Markdown
Member

And I have other new questions:

  1. need some e2e test case
  2. need a way to purge the old cache

@agile6v

agile6v commented Mar 2, 2020

Copy link
Copy Markdown
Member Author

How about the new style? I think the new style is simpler.

# current style
"proxy-cache": {
    "cache_key": ["$uri"]
    "cache_bypass": ["$arg_bypass"],
    ... ...
}
# new style
"proxy-cache": {
    "cache_key": ["uri"]
    "cache_bypass": ["arg_bypass"],
    ... ...
}

Here can use variables or strings, so need an identifier to distinguish it.

@agile6v

agile6v commented Mar 2, 2020

Copy link
Copy Markdown
Member Author

And I have other new questions:

  1. need some e2e test case
  2. need a way to purge the old cache

I'm also considering these things. For 2 if there is no better solution, cache purge script will be the final choice.

@agile6v

agile6v commented Mar 2, 2020

Copy link
Copy Markdown
Member Author

And I have other new questions:

  1. need some e2e test case
  2. need a way to purge the old cache
  1. e2e test cases I haven't figured it out yet. Do you have any suggestions?
  2. Added. Users only need to specify the method=PURGE to delete cache file. Please review it.

Thanks.

Comment thread lua/apisix/plugins/proxy-cache.lua
@agile6v

agile6v commented Mar 3, 2020

Copy link
Copy Markdown
Member Author

And I have other new questions:

  1. need some e2e test case
  2. need a way to purge the old cache
  1. e2e test cases I haven't figured it out yet. Do you have any suggestions?
  2. Added. Users only need to specify the method=PURGE to delete cache file. Please review it.

Thanks.

@moonming @membphis

Comment thread lua/apisix/plugins/proxy-cache.lua Outdated
Comment thread lua/apisix/plugins/proxy-cache.lua Outdated
@agile6v

agile6v commented Mar 5, 2020

Copy link
Copy Markdown
Member Author

Do you have any suggestions for the test cases?

Moreover, I think I should figure out the logic of the APISIX test cases.

Thanks.

@agile6v

agile6v commented Mar 12, 2020

Copy link
Copy Markdown
Member Author

Please review @moonming @membphis

@moonming

Copy link
Copy Markdown
Member

LGTM. Need add this plugin to README.md.
@membphis please take a look about how to add test cases.

@agile6v

agile6v commented Mar 12, 2020

Copy link
Copy Markdown
Member Author

OK. I'll add it to README. Basically test cases are covered.

@agile6v

agile6v commented Mar 14, 2020

Copy link
Copy Markdown
Member Author

@membphis ping

Comment thread t/plugin/proxy-cache.t Outdated
Comment thread t/plugin/proxy-cache.t
Comment thread lua/apisix/plugins/proxy-cache.lua
@membphis

Copy link
Copy Markdown
Member

@agile6v It seems that you have to rebase your branch, this branch has conflicted with master branch.

@agile6v

agile6v commented Mar 15, 2020

Copy link
Copy Markdown
Member Author

@agile6v It seems that you have to rebase your branch, this branch has conflicted with master branch.

Resolved.

Comment thread lua/apisix/plugins/proxy-cache.lua
Comment thread t/plugin/proxy-cache.t
@membphis

Copy link
Copy Markdown
Member

LGTM, we can merge it after run the test cases.

@membphis
membphis merged commit 864aa16 into apache:master Mar 15, 2020
@membphis

Copy link
Copy Markdown
Member

merged, many thx @agile6v

@agile6v
agile6v deleted the dev branch March 16, 2020 12:03
SaberMaster pushed a commit to SaberMaster/incubator-apisix that referenced this pull request Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: introduce proxy caching plugin

3 participants