[openstreetmap/openstreetmap-website] Enable cache of XML fragment for node, way and relation (PR #3813)

yuiseki notifications at github.com
Sun Nov 20 14:42:39 UTC 2022


## What

This pull request changes just three files on this rails application
- `app/views/api/nodes/_node.xml.builder`
- `app/views/api/ways/_way.xml.builder`
- `app/views/api/relations/_relation.xml.builder`

## Why

- Currently, this rails app does not cache fragment of XML
- This should slow down the XML building
- Whether the caching mechanism is memory or files, it should be faster than executing SQL queries and building XML
- These files appear to have been last edited four years ago, but modern Rails' caching of XML fragments has progressed

## How

- Change the Rails Model instance handled by `*.xml.builder` to be passed to `cache` method of the Rails view
- If there are no changes to the records in the Rails Model, the SQL query execution and XML construction will be skipped and the cache will be used
- If the Rails Model record changes, the cache is destroyed and the XML is updated appropriately

## My opinion

- This change should be carefully considered as it will likely affect the behavior of the Production environment
- Still, I believe it should have a big positive impact on performance
- Please consider it and let me know what you think!



You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/3813

-- Commit Summary --

  * Enable cache of XML fragment for node, way and relation

-- File Changes --

    M app/views/api/nodes/_node.xml.builder (40)
    M app/views/api/relations/_relation.xml.builder (32)
    M app/views/api/ways/_way.xml.builder (32)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/3813.patch
https://github.com/openstreetmap/openstreetmap-website/pull/3813.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/3813
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/3813 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20221120/2268bb09/attachment-0001.htm>


More information about the rails-dev mailing list