# Dash Ag Grid Refresh Cache and Purge Cache

**URL:** <https://community.plotly.com/t/dash-ag-grid-refresh-cache-and-purge-cache/75985>\
**Category:** Dash Python\
**Tags:** question\
**Created:** [June 10, 2023, 10:40am UTC](https://community.plotly.com/t/dash-ag-grid-refresh-cache-and-purge-cache/75985 "2023-06-10T10:40:23Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![sergeyvyazov](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/sergeyvyazov/32/24337_2.png) [@sergeyvyazov](https://community.plotly.com/u/sergeyvyazov)\
**Post date:** [July 7, 2023, 1:53pm UTC](https://community.plotly.com/t/dash-ag-grid-refresh-cache-and-purge-cache/75985/15 "2023-07-07T13:53:28Z")

</div>

Good afternoon! I used your answer (example at the link). Implemented. And purge cache works. But does not update all cached blocks above. Updates only the last loaded block. Tell me how to fix this? It is necessary that the previous block is also updated. I will attach an image of what the process looks like if it stops at the junction of two blocks

```
from dash import Dash, html, Input, Output, no_update, State, ctx
from dash_ag_grid import AgGrid
import dash_mantine_components as dmc
import pandas as pd

df = pd.read_csv(
        "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv"
    )
app = Dash()

# basic columns definition with column defaults
columnDefs = [{"field": c} for c in df.columns]

app.layout = html.Div(
    [
        AgGrid(
            id="grid",
            columnDefs=columnDefs,
            defaultColDef={"resizable": True, "sortable": True, "filter": True},
            rowModelType="infinite",
            dashGridOptions={
                # "pagination": True
            },
            style={"height": 900, "width": "100%"},
        ),
        dmc.ChipGroup(
            [dmc.Chip(x, value=x) for x in ["United States", "Afghanistan"]],
            value="United States",
            id="filters",
        ),
        html.Button(id="fire-filters", children="Fire Filters"),
    ]
)

@app.callback(
    Output("grid", "getRowsResponse"),
    Input("grid", "getRowsRequest"),
    State("filters", "value"),
)
def update_grid(request, filters_data):
    if request:
        filtered_df = df[df['country'] == filters_data]

        partial = filtered_df.iloc[request["startRow"]: request["endRow"]]
        return {"rowData": partial.to_dict("records"), "rowCount": len(filtered_df.index)}

app.clientside_callback(
    """function (n) {
        dash_ag_grid.getApi('grid').purgeInfiniteCache()
        return dash_clientside.no_update
    }""",
    Output("fire-filters", "n_clicks"),
    Input("fire-filters", "n_clicks"),
    prevent_initial_call=True
)

if __name__ == ' __main__':
    app.run(debug=True)

```

 ![Снимок экрана 2023-07-07 165220](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/7/a/7a378821995e041169cf799a7cdf9b0e0f7c9ac8.png)

---

_[View the full topic](https://community.plotly.com/t/dash-ag-grid-refresh-cache-and-purge-cache/75985)._
