Summary
While reviewing controllers, found that HTTP caching (check_last_modified / check_last_modified_segment / check_last_modified_collection) is applied inconsistently. Some read endpoints emit Last-Modified / Cache-Control and support 304 Not Modified revalidation; others don't, so clients re-fetch full payloads unnecessarily.
There are two distinct root causes — one is a controller-layer gap, the other is a model-layer gap.
Background
check_last_modified* lives in helpers/http_cache_helper.rb. It only works for models registered as cacheable resources — i.e. models that declare cache_timeout (and usually cache_segment_instance) in ontologies_linked_data. LinkedData::HTTPCache::CacheableResource is mixed into every model via base.rb, but max_age reads cache_settings[:cache_timeout].first, so a model that never calls cache_timeout is not a functioning cacheable resource.
| Model |
cache_timeout declared? |
Controller calls check_last_modified*? |
Class |
yes (86400) |
yes |
Instance (named_individual) |
yes (14400) |
yes |
OntologySubmission |
yes (3600) |
yes |
SKOS::Collection |
yes (14400) |
no |
SKOS::Scheme |
yes (14400) |
no |
SKOS::Label (skosxl) |
no |
no |
| property models (object/datatype/annotation/ontology_property) |
no |
no |
Gap 1 — controller layer (models already cacheable)
SKOS::Collection and SKOS::Scheme models already declare cache_timeout 14400, but collections_controller and schemes endpoints never call check_last_modified*. These were added in the 2025-06 SKOS batch (collections/schemes/labels) which landed without wiring caching into the controllers.
Gap 2 — model layer (not cacheable at all)
Neither the property models nor SKOS::Label declare cache_timeout, so they are not cacheable resources. The properties_controller has had no caching since it was created (2013); skos_xl_label_controller is new (2025) and the Label model was never made cacheable.
Notes
- Cross-repo: Gap 2 requires model changes in
ncbo/ontologies_linked_data first.
check_last_modified* must only be invoked on GET routes (it can short-circuit with 304); do not add it to mixed-method handlers blindly.
- Discovered while doing the
before-filter / boilerplate dedup work on the classes/instances controllers.
Summary
While reviewing controllers, found that HTTP caching (
check_last_modified/check_last_modified_segment/check_last_modified_collection) is applied inconsistently. Some read endpoints emitLast-Modified/Cache-Controland support304 Not Modifiedrevalidation; others don't, so clients re-fetch full payloads unnecessarily.There are two distinct root causes — one is a controller-layer gap, the other is a model-layer gap.
Background
check_last_modified*lives inhelpers/http_cache_helper.rb. It only works for models registered as cacheable resources — i.e. models that declarecache_timeout(and usuallycache_segment_instance) inontologies_linked_data.LinkedData::HTTPCache::CacheableResourceis mixed into every model viabase.rb, butmax_agereadscache_settings[:cache_timeout].first, so a model that never callscache_timeoutis not a functioning cacheable resource.cache_timeoutdeclared?check_last_modified*?ClassInstance(named_individual)OntologySubmissionSKOS::CollectionSKOS::SchemeSKOS::Label(skosxl)Gap 1 — controller layer (models already cacheable)
SKOS::CollectionandSKOS::Schememodels already declarecache_timeout 14400, butcollections_controllerandschemesendpoints never callcheck_last_modified*. These were added in the 2025-06 SKOS batch (collections/schemes/labels) which landed without wiring caching into the controllers.check_last_modified*to the SKOS collections/schemes read endpoints (no model change required).Gap 2 — model layer (not cacheable at all)
Neither the property models nor
SKOS::Labeldeclarecache_timeout, so they are not cacheable resources. Theproperties_controllerhas had no caching since it was created (2013);skos_xl_label_controlleris new (2025) and theLabelmodel was never made cacheable.cache_timeout/cache_segment_instanceto the relevant models in ncbo/ontologies_linked_data, then callcheck_last_modified*in the controllers here.Notes
ncbo/ontologies_linked_datafirst.check_last_modified*must only be invoked on GET routes (it can short-circuit with304); do not add it to mixed-method handlers blindly.before-filter / boilerplate dedup work on the classes/instances controllers.